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

Retain filter values on pragmatically created grid

1 Answer 234 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 27 Jul 2015, 02:44 AM

Hi All,

I'm creating my grid pragmatically using the approach described here: 

http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/defining-structure/changing-the-grid-structure-dynamically-on-postback

It works fine with only one concern - it only retain one column filter value at every turn. Let's say a user filtered results using the first filter. As soon as a second filter is selected, the first filter value will be lost after postback whereas the second filter value remains now. Users need to apply multiple column filters to get the desired results, is there a way to retain all filter values entered by users ?

I can't use bellow scripts because the grid is pragmatically created in Page_Init event and added to the placeholder control

var grid = $find("<%= RadGrid.ClientID %>");

            if (grid.get_clientState()) {
                var clientState = $.parseJSON(grid.get_clientState());
                var keys = clientState.checkListFilterKeys;

                for (var i = 0; i < keys.length; i++) {
                    var selectedValues = clientState.checkListFilterValues[i];
                    var fieldName = keys[i].split(",")[1];
                    var filterCell = grid.MasterTableView._getFilterCellByColumnUniqueName(fieldName);
                    var inputElement = filterCell.children[0];
                    inputElement.value = selectedValues.join(", ");
                }
            }

 â€‹Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 30 Jul 2015, 05:36 AM
Hello John,

If you are not removing/adding different columns dynamically, you can set the EnableColumnsViewState property to True and see whether this resolves the issue.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or