Shared remote DataSource with different filters in Grid

8 posts, 0 answers
  1. Frik
    Frik avatar
    9 posts
    Member since:
    Jan 2012

    Posted 10 Feb 2012 Link to this post

    Hi,

    I need to bind to a remote json DataSource that is used by 2 Grids.  Easy enough.

    However, I need a different filter of the same data for each Grid.  What is the best way to accomplish this without loading the data twice from the remote server?

    Thanks!
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 10 Feb 2012 Link to this post

    Hello,

     This is not possible with a single data source. Filtering it would rebind both grids. You need two datasources. 

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Frik
    Frik avatar
    9 posts
    Member since:
    Jan 2012

    Posted 10 Feb 2012 Link to this post

    1.  How do I create a duplicate of a datasource without reloading it from the server so that I can apply a different filter to it?

    2.  Can you please add this as a feature request?  Or add a proxy to a datasource that will allow us to do that.
  4. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 10 Feb 2012 Link to this post

    Hi,

    You cannot have two remote data sources without making two requests for the data. At least one of the data sources should not be remote (you can use the data of the other data source to feed it).


    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. Frik
    Frik avatar
    9 posts
    Member since:
    Jan 2012

    Posted 10 Feb 2012 Link to this post

    That is my question... how do I use a local datasource and feed it a copy of the data from the remote data source?
  6. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 13 Feb 2012 Link to this post

    Hi,

     Something like this should work:

    remoteDataSource.change(function() {
            localDataSource.data(this.data());
    });

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  7. Jacques
    Jacques avatar
    3 posts
    Member since:
    Sep 2012

    Posted 18 Feb 2013 Link to this post

    The last solution posted is working, thank you!

    However, what bothers me is that the remoteDataSource must know about the local dataSources. Is there any way to bind the localDataSource to the remoteDataSource while defining the localDataSource?

    Something like:

    $("#dropDownAdrResVille").kendoComboBox({
            dataTextField: "Nom",
            dataValueField: "ID",
            dataSource: new kendo.data.DataSource({ data: Common.villesDataSource.data() }),
            change: function() {
                Representant.ViewModel.representant.AdresseResidentielle.VilleID = this.value();
            }
        }).data("kendoComboBox");

    ?
  8. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 19 Feb 2013 Link to this post

    Hi,

     Your code will work only if the vilesDataSource is already populated at the time the combobox is created. Otherwise data() will return empty array. If this is not the case use my previous suggestion.

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top