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

Programatically Group Grid

2 Answers 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
HUA
Top achievements
Rank 1
HUA asked on 04 Dec 2013, 05:43 PM
Dear Kendo Team,
I keep the settings of the datasource of each grid , in database ,(Paging,Sorting,Filtering,Aggregate and Grouping) as it treats server-side and this is more confortable for the client.
Grouping works as expected when is fired with drag&drop event, but i doesn't work when I send the grouping option without event triggered....
So the question is : how can I emulate this event in order to retrieve the grid grouping following the settings send... (code below, the parameterMap function used)

function paramCustomFunc(options, operation) {
    var KendoOptionGrid = FormatGridOptions(options);//format options
    var userSettings = null;
    if (ArrayFistLoad == null)
        ArrayFistLoad = new Array();
    if (ArrayFistLoad[ActiveGrid.Name] == null) {//Ensure that it first time that datasource read is called in order to apply the user custom settings
        if (PreferenceUser != null) {
            var data = PreferenceUser.data.Data[0];//retrieve data preference
            for (var i = 0; i < data.GridSettings.length; i++) {
                if (data.GridSettings[i].Datagrid == ActiveGrid.Name) {//page can contain more than 1 datagrid, so find the good settings related to datagrid
                    userSettings = data.GridSettings[i];
                    break;
                }
            }
        }
 
    }
    if (userSettings != null) {
 //if it first time and i've got specific settings, apply it 
        if(userSettings.Paging != null){
            KendoOptionGrid.Paging.page userSettings.Paging.page;
            KendoOptionGrid.Paging.skip = userSettings.Paging.skip;
            KendoOptionGrid.Paging.take = userSettings.Paging.take;
            KendoOptionGrid.Paging.pageSize = userSettings.Paging.take;
        }
        KendoOptionGrid.Grouping =  userSettings.Grouping;
        KendoOptionGrid.Filtering = userSettings.Filtering;
        KendoOptionGrid.Sorting = userSettings.Sorting;
        KendoOptionGrid.Aggregates = userSettings.Aggregates;
         
    }
    ArrayFistLoad[ActiveGrid.Name] = 1;
    return JSON.stringify({ optionGrid: KendoOptionGrid, operation: operation });
}
Thanks for your answer.
Best regards

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 06 Dec 2013, 01:05 PM
Hi,

You should use the dataSource query method to restore the state. The dataSource will not be aware that there are groups when just the options are send to the server. I would also suggest to check this code-library project which demonstrates how the state can be preserved in a cookie. You can use the same approach to save the state on the server. The only difference will be in how the state is loaded and saved.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
HUA
Top achievements
Rank 1
answered on 06 Dec 2013, 05:50 PM
Hi Daniel,
Thanks for your reply.
It works as expected :)
Best regards
Tags
Grid
Asked by
HUA
Top achievements
Rank 1
Answers by
Daniel
Telerik team
HUA
Top achievements
Rank 1
Share this question
or