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

Grid expad collapse after refresh

3 Answers 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ivan
Top achievements
Rank 1
Ivan asked on 29 Jan 2015, 06:28 PM
I am building a page which contains a Grid. The user can expand and collapse groups as they want. I want to be able to preserve the group states (expanded/collapsed) on the client.

What I tried was to hook up to the 'onRequestStart' event and try to save which groups are expanded and which are collapsed. Then on 'onRequestEnd' I would just go through the list again and expand/collapse groups as needed.

Is there an elegant way to achieve this or do I have to manually crawl through each element and set it's expanded states?

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 03 Feb 2015, 11:48 AM
Hello Ivan,

Generally, you can persist the groups using the persistence framework control:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/persisting-grid-settings/defaultcs.aspx?product=grid

Hope this helps.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Ivan
Top achievements
Rank 1
answered on 06 Feb 2015, 11:58 AM
Thanks for that. It fixed some of my problems.

I just have one more question for you.

I have currently this code:

var array__Obf = [];
var masterTableView__Obf;
 
gridCreated__Obf = function (sender) {
    masterTableView__Obf = sender.get_masterTableView();
};
 
saveGrouping__Obf = function (sender, args) {
    array__Obf = [];
    $(masterTableView__Obf.get_element()).find("td").filter(function () {
        if ($(this)[0].firstChild !== null && $(this)[0].firstChild.className === "rgExpand" && $(this)[0].firstChild.type === "submit")
            return true;
        return false;
    }).each(function () {
        array__Obf.push($(this)[0].nextSibling.innerText);
    });
}
 
restoreGrouping__Obf = function () {
    if (array__Obf.length === 0)
        return;
    $(masterTableView__Obf.get_element()).find("td").filter(function () {
        if ($(this)[0].nextSibling !== null && array__Obf.indexOf($(this)[0].nextSibling.innerText) !== -1)
            return true;
        return false;
    }).each(function () {
        this.firstChild.click();
    });
}

What I would like to have is something like this

initializeGrid__Obf = function (gridClientId__Obf)
{
    clientId__Obf = $(gridClientId)
    clientId__Obf.ajaxStart = saveGrouping__Obf;
    clientId__Obf.ajaxComplete = restoreGrouping__Obf;
}

This way I could get rid of a little of the markup and people could easily reuse it for other things.

Is something like this possible?

0
Eyup
Telerik team
answered on 11 Feb 2015, 11:46 AM
Hi Ivan,

Generally, the OnRequestStart and OnResponseEnd event handlers can be used in similar scenarios:
http://www.telerik.com/help/aspnet-ajax/ajax-onrequeststart.html

However, please note that this approach is too custom and beyond our support scope.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Ivan
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Ivan
Top achievements
Rank 1
Share this question
or