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

Trying to use new Save State / Load State, problem with filter rows

11 Answers 192 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 20 Nov 2014, 07:45 PM
I have a grid that I'm trying to use the Load State method on as seen in the webinar this morning.

Using this code:

var grid = $("#gridDiv1").data("kendoGrid");
var options = localStorage["kendo-grid-options"];
 
if (options) {
    grid.setOptions(JSON.parse(options));
}


It restores the column order and sizes (which I want), but messes up some of the header filtering. I have a two row header, customized to show either the filter button in the upper row or a filter cell in the lower row, or both. When reloading the state, the settings are lost. For example, and the most important glitch, I have a filter cell that is KendoNumericTextBox on which I do not want the spinners, but they appear on load state.

I tried accessing the item programmatically and resetting the spinners = false setting, but had no luck, and that would be insufficient to solve the problem anyway.

Thanks, Bob Graham

11 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 24 Nov 2014, 02:15 PM

Hello Robert,

Can you please check the following example and edit it in order to show your exact setup so we can take a
look?

http://dojo.telerik.com/ehUDO

This is needed because, we need to know your exact setup and be able to reproduce the issue.

Thank you for the cooperation.

Regards,

Kiril Nikolov

Telerik

 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 

 

0
Andrew
Top achievements
Rank 1
answered on 25 Nov 2014, 02:41 PM
I'm having the same issue.  My filter dropdowns are empty after loading the state.

The only real difference I can see between the example and my code is that I'm using a local datasource.

I'm curious, what information is actually being saved when saving state?  Upon inspecting the JSON string it seems that not only the grid state but the actual data is being stored.  Is there a way to just store column order + settings and currently applied filters only?  I already have a way of doing this thats faster and works though would be nice to have this feature built in.
0
Andrew
Top achievements
Rank 1
answered on 25 Nov 2014, 02:46 PM
Probably should have mentioned that the data isn't showing in the grid at all either after loading.
0
Kiril Nikolov
Telerik team
answered on 27 Nov 2014, 08:22 AM
Hello Andrew,

getOptions() method will save all the options of the Kendo UI Grid and its dataSource. If you set the data as an option passed to the data option of the dataSource, then it will be saved with the getOptions() as well. If you bind the data using the transport option, then the data will not be saved.

As for the issue that you are facing - send us a sample that we can look at and we will be happy to assist you on resolving the issue.

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Oscar Agusti
Top achievements
Rank 1
answered on 26 Oct 2015, 03:30 PM

Hi Kiril,

I'm using the kendo.stringify(grid.getOptions()) and grid.setOptions(JSON.parse(options)) and the filter rows are loaded successfully. The problem is that I´m using a toolbar template and when I load the grid state, the toolbar is disappearing.

How could I recover the custom toolbar?

Best regards

0
Kiril Nikolov
Telerik team
answered on 27 Oct 2015, 09:55 AM

Hello Oscar Agusti,

 

Please check the following sample project and let me know if it helps:

 

http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/how-to/grid-preserve-server-toolbar-template-after-set-options

 

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Oscar Agusti
Top achievements
Rank 1
answered on 28 Oct 2015, 04:20 PM

Hi Kiril,

 

Thanks for the information. Now, the toolbar is preserved fine.

 

Best regards

0
Kiril Nikolov
Telerik team
answered on 29 Oct 2015, 09:40 AM

Hello Oscar Agusti,

 

I am happy to hear that the issue is resolved.

 

In case you have any further questions, please do not hesitate to contact us.

 

Regards,
Kiril Nikolov
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 16 Dec 2015, 02:29 PM

Hello Kiril,

I have similar situation. My grid has function to initialize filer - grid_GroupFilter. But getOptions() does not save it. Is it a bug?

Grid:
    $("#grid").kendoGrid({
        dataSource: dataSource,
        pageable: {
            pageSize: 15, pageSizes: [10, 15, 20], info: true, input: true, previousNext: true, refresh: true
        },
        toolbar: ["create"],
        columns: [
            { field: "name", title: "Group",
                template: "#=name#&nbsp;<a href='\\#' onclick='openGroupInfo(#= groupId #);return false;' class='btn-open-info'></a>",
                filterable: { ui: grid_GroupFilter, messages: { filter: "Search", info: ""} }
            },
            { title: "Members",
                template: "<a href='\\#' onclick='openApprovalGroupUser(#= groupId #);return false;'>Members</a>", filterable: false
            },
            { field: "active", title: "Active", width: "70px",
                template: "<input type='checkbox' #= active?'checked':'' # disabled/>", filterable: false
            },
            { command: ["edit", "destroy"], title: "&nbsp;", width: "220px" }
        ],
        editable: "inline",
        mobile: true,
        filterable: { extra: false },
        filterMenuInit: grid_filterMenuInit
    });
}

getOptions() string:
{"prefix":"","name":"Grid","columns":[{"encoded":true,"field":"name","title":"Group","template":"#=name#&nbsp;<a href='\\#' onclick='openGroupInfo(#= groupId #);return false;' class='btn-open-info'></a>","filterable":{"messages":{"filter":"Search","info":""}},"headerAttributes":{"id":"6f0b6a3b-a58d-47a3-bb83-5fb7b827086e"}},{"encoded":true,"title":"Members","template":"<a href='\\#' onclick='openApprovalGroupUser(#= groupId #);return false;'>Members</a>","filterable":false,"headerAttributes":{"id":"3ced0d7c-cdfa-4f03-9969-1f6277af31b8"}},{"encoded":true,"field":"active","title":"Active","width":"70px","template":"<input type='checkbox' #= active?'checked':'' # disabled/>","filterable":false,"headerAttributes":{"id":"b84cc60c-bc93-4c41-950b-5b0356921e3c"}},{"encoded":true,"command":["edit","destroy"],"title":"&nbsp;","width":"220px","headerAttributes":{"id":"5ceb0318-d77d-4edb-b756-fd24513dba1f"}}],"toolbar":["create"],"autoBind":true,"filterable":{"extra":false},"scrollable":true,"sortable":false,"selectable":false,"allowCopy":false,"navigatable":false,"pageable":{"pageSize":15,"pageSizes":[10,15,20],"info":true,"input":true,"previousNext":true,"refresh":true},"editable":"inline","groupable":false,"rowTemplate":"","altRowTemplate":"","noRecords":false,"dataSource":{"data":null,"schema":{"model":{"id":"groupId","fields":{"groupId":{"editable":false,"type":"number"},"name":{"validation":{"required":true},"type":"string"},"active":{"type":"boolean","defaultValue":true}}}},"offlineStorage":null,"serverSorting":false,"serverPaging":true,"serverFiltering":true,"serverGrouping":false,"serverAggregates":false,"batch":false,"transport":{"dataSource":null},"pageSize":15,"page":1,"filter":null,"group":[]},"height":null,"resizable":false,"reorderable":false,"columnMenu":false,"detailTemplate":null,"columnResizeHandleWidth":3,"mobile":true,"messages":{"editable":{"cancelDelete":"Cancel","confirmation":"Are you sure you want to delete this record?","confirmDelete":"Delete"},"commands":{"create":"Add new record","cancel":"Cancel changes","save":"Save changes","destroy":"Delete","edit":"Edit","update":"Update","canceledit":"Cancel","excel":"Export to Excel","pdf":"Export to PDF"},"noRecords":"No records available."},"excel":{"proxyURL":"","allPages":false,"filterable":false,"fileName":"Export.xlsx"},"pdf":{"fileName":"Export.pdf","proxyURL":"","paperSize":"auto","allPages":false,"landscape":false,"margin":null,"title":null,"author":null,"subject":null,"keywords":null,"creator":"Kendo UI PDF Generator","date":null}}

0
Kiril Nikolov
Telerik team
answered on 18 Dec 2015, 10:08 AM

Hello Ruben,

 

Would it be possible to create a separate support request, with more details about the issue that you are having, and we will be happy to help.

 

Regards,
Kiril Nikolov
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 19 Dec 2015, 09:55 PM

Hello Kiril,

 Thank you for reply. I have created new thread http://www.telerik.com/forums/problem-with-filter-using-getoptions-setoptions

Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Andrew
Top achievements
Rank 1
Oscar Agusti
Top achievements
Rank 1
Ruben
Top achievements
Rank 1
Share this question
or