This is a migrated thread and some comments may be shown as answers.

Problem with filter using getOptions/setOptions

2 Answers 623 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ruben
Top achievements
Rank 1
Ruben asked on 19 Dec 2015, 09:53 PM

Hello Kiril,

I created this new thread per your request.

Here is my problem. I have a pageable grid with filter and dropdown. It works fine until options are saved and restored from SessionStorage. The reason I use SessionStorage, because my grid has a link to another web page. When user comes back, I need to know what last grid page was active. So, grid script has reference to function:
{ field: "ProductName", title: "Product",
           filterable: { ui: grid_Filter, messages: { filter: "Search", info: ""} }
          }

But this function (grid_Filter) is missing in string that returned by getOptions() :
"field":"ProductName","title":"Product","filterable":{"messages":{"filter":"Search","info":""}}

Here is example: http://dojo.telerik.com/AQAVO

When you click on filter sign, you can see dropdown with data. If you click “Save and Restore” button and then click on filter sign again, dropdown is gone.
Is it a bug? I am looking for a work around how to set filter after setOptions.

Thank you.

2 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 23 Dec 2015, 12:58 PM

Hello Ruben,

 

Actually this is not a bug, but rather how the JSON.stringify method works. As stated in the setOptions article: JSON.stringify() cannot serialize function references (e.g. event handlers), so if stringification is used for the retrieved Grid state, all configuration fields, which represent function references, will be lost. You have two options to avoid this limitation: use a custom implementation to serialize JavaScript functions, or add the function references back to the deserialized configuration object before passing it to the setOptions method.

 

An http://dojo.telerik.com/UtUHu example demonstrates how to add the function references back to the deserialized configuration object before passing it to the setOptions method.

 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ruben
Top achievements
Rank 1
answered on 04 Jan 2016, 01:55 PM
Thank you, Boyan
Tags
Grid
Asked by
Ruben
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Ruben
Top achievements
Rank 1
Share this question
or