I try to keep filter value on reload but not working.

0 Answers 92 Views
Data Source Grid
Patrice
Top achievements
Rank 1
Patrice asked on 20 Apr 2022, 06:56 PM | edited on 20 Apr 2022, 07:11 PM
Hi,



I'm trying to keep the filter value into KendoGrid and reuse it on relaod. 

I find some code sample but doesn't working. I used getOptions to store values into localStorage. It's working. I have values into localStorage["kendo-grid-options"]. On reload, value appears into filters on header grid but data don't load. Error in the consoel is : 

[! - SessionID: q0pbq0zsol3mjsxtd5mlendu, PageInstanceID: d11a8e2e-d716-43a0-8f4e-679eb87ad167, DateTime: 04/20/2022 20:53:10.894] Message: Uncaught 
TypeError: Cannot read properties of undefined (reading 'data')

Impossible to find solution. If somebody has en idea... :)

My code is the following

function LoadSampleQualityControlPlanGridSummary(control,params) 
{
control.dataSource = new kendo.data.DataSource({
transport: {
read: function (options) {
GetDsBySp("sp_HMI_GetSampleControlPlanList", params, options.success);}
},
schema: {
model: {
id: "qm_spec_id"
},
fields: {
qm_spec_desc: {
type: "string"
},
plan_name: {
type: "string"
}
}
}
});
}

function InitSampleQualityControlPlanSummaryGrid(control) {
control.columns = [
{
field: "qm_spec_name",
title: "Name")
},
{
field: "qm_spec_desc",
title: "description")
},
{
field: "plan_name",
title: "Plan",
}
];
}

//On load
_controls.SampleControlPlanSummary = control.findByXmlNode("GSQCP");
_controls.$SampleControlPlanSummary = $(_controls.SampleControlPlanSummary.domElement).data("kendoGrid");

InitSampleQualityControlPlanSummaryGrid(_controls.SampleControlPlanSummary);

var options = localStorage["kendo-grid-options"];
    if (options) {
        var parsedOptions = JSON.parse(options);
    _controls.$SampleControlPlanSummary.setOptions(parsedOptions);
_controls.$SampleControlPlanSummary.setDataSource(gridData);
    }
LoadSampleQualityControlPlanGridSummary(_controls.SampleControlPlanSummary, paramControl);
Veselin Tsvetanov
Telerik team
commented on 25 Apr 2022, 07:22 AM

Hi Patrice,

I believe the issue in the case in question is the fact that you are resetting the Grid DataSource after passing the cached options:

 _controls.$SampleControlPlanSummary.setOptions(parsedOptions);
_controls.$SampleControlPlanSummary.setDataSource(gridData); 

Please, note that the stored Grid options object will keep the DataSource state too. Therefore, it should not be further altered by a setDataSource() call on the same widget instance.

No answers yet. Maybe you can help?

Tags
Data Source Grid
Asked by
Patrice
Top achievements
Rank 1
Share this question
or