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!
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!
7 Answers, 1 is accepted
0
Hello,
Atanas Korchev
the Telerik team
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!
0
Frik
Top achievements
Rank 1
answered on 10 Feb 2012, 05:36 PM
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.
2. Can you please add this as a feature request? Or add a proxy to a datasource that will allow us to do that.
0
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
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!
0
Frik
Top achievements
Rank 1
answered on 10 Feb 2012, 07:54 PM
That is my question... how do I use a local datasource and feed it a copy of the data from the remote data source?
0
Hi,
Atanas Korchev
the Telerik team
Something like this should work:
remoteDataSource.change(function() {
localDataSource.data(this.data());
});
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!
0
Jacques
Top achievements
Rank 1
answered on 18 Feb 2013, 09:05 PM
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");
?
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");
?
0
Hi,
Atanas Korchev
the Telerik team
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!
Mark
commented on 16 May 2023, 08:27 PM
Top achievements
Rank 1
not sure if anyone cares, but this works now....
Calling datasource.read()...then in the "complete" event in the transport, read: json.....
complete: function (xhr) {
const data = xhr.responseJSON;
let gridCOBRA = $('#grid_COBRA').data('kendoGrid');
let gridDependents = $('#grid_Dependents').data('kendoGrid');
var cobraDS = data.filter(c => c.code == "CP");
gridCOBRA.setDataSource(cobraDS);
gridCOBRA.refresh();
var dependDS = data.filter(c => c.code == "DP");
gridDependents.setDataSource(dependDS);
gridDependents.refresh();
}
},
Nikolay
commented on 19 May 2023, 11:15 AM
Telerik team
Hi Mark,
Thank you for sharing this with the community.
I am sure it will be helpful to others facing the same scenario.
Regards,
Nikolay