Retain filter values on pragmatically created grid

2 posts, 0 answers
  1. John
    John avatar
    1 posts
    Member since:
    Jul 2015

    Posted 26 Jul 2015 Link to this post

    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

  2. Eyup
    Admin
    Eyup avatar
    3699 posts

    Posted 30 Jul 2015 Link to this post

    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
Back to Top