Can I save and after that Reload the filters state in Ext.NET Grid view

Page 1 of 2 12 LastLast
  1. #1

    Can I save and after that Reload the filters state in Ext.NET Grid view

    Hi guys,
    I'm using Ext.NET grid view and have successfully created filters for my Grid
                   <Plugins>
                        <ext:GridFilters runat="server" ID="GridFilters1" Local="true">
                            <Filters>
                                <ext:NumericFilter DataIndex="Id" />
                                <ext:StringFilter DataIndex="Company" />
                                <ext:NumericFilter DataIndex="Price" />
                                <ext:DateFilter DataIndex="Date">
                                    <DatePickerOptions runat="server" TodayText="Now" />
                                </ext:DateFilter>
                                <ext:ListFilter DataIndex="Size" Options="extra small,small,medium,large,extra large" />
                                <ext:BooleanFilter DataIndex="Visible" />
                            </Filters>
                        </ext:GridFilters>
                    </Plugins>
    Can I save the state of the filters and then reload them later?
  2. #2
    Hi,

    Please try the following.

    1. Save a state this way:
    var filtersState = grid.filters.saveState(grid, {});
    2. Restore the state this way:
    grid.filters.applyState(grid, filtersState);
  3. #3
    Thank you a million times, Daniil. When I started to think that it's impossible, your answer is really a life saver. You rock
  4. #4
    Can you achieve this from server side in code behind as well?
  5. #5
    Hello,

    Generally, no.

    But you can send filters' state to a server as a DirectEvent's parameter.

    Then call a JavaScript function from a server to restore filters.
  6. #6

    SaveState and ASP-MVC-GridPanel

    Quote Originally Posted by Daniil View Post
    Hi,

    Please try the following.

    1. Save a state this way:
    var filtersState = grid.filters.saveState(grid, {});
    2. Restore the state this way:
    grid.filters.applyState(grid, filtersState);
    Hi,
    How can I combine this with the GridPanel?

    I have the asp-MVC code: @( Html.X().GridPanel()...

    How can I work with javascript and refer the Grid?

    What is 'grid' in the example javascript code?

    Kind regards
  7. #7
    Hi @L2gmbh,

    Welcome to the Ext.NET forums!

    What is 'grid' in the example javascript code?
    It is a GridPanel JavaScript instance.

    If you set up
    .ID("GridPanel1")
    for the GridPanel in the Razor view, there is a good chance to access it in JavaScript by this:
    App.GridPanel1
  8. #8

    Loading Filterstate

    If you set up
    .ID("GridPanel1")
    for the GridPanel in the Razor view, there is a good chance to access it in JavaScript by this:
    App.GridPanel1
    [/QUOTE]


    Hi, Thanks, Now I'm almost there :-)
    But the last Step dont work, loading a filterstate in the grid.
    I do this js-code:

    App.GridPanel1.filters.applyState(App.GridPanel1, filtersState);

    but the Grid dont change.

    filterstate is filled, and App.GridPanel1 is filled.

    Whats wrong?

    Kind regards
  9. #9
    Could you provide a test case, please?
  10. #10
    Quote Originally Posted by Daniil View Post
    Could you provide a test case, please?
    <script>
            var filtersState;
    
            function save() {
                filtersState = App.GridPanel1.filters.saveState(App.GridPanel1, {});
                alert(filtersState.toString());
            };
            
            function load() {
                App.GridPanel1.filters.applyState(App.GridPanel1, filtersState);
                alert(filtersState);
            };
        </script>
    }
    
    
    
    
    
    <input type="button" value="load" onclick="load();" />
    <input type="button" value="speichern" onclick="save();" />
    
    
    @(
        Html.X().GridPanel()
                .ID("GridPanel1")
                .Title("foo")
                .Frame(true)
                .Height(600)            
                .Store(...
    Help this?
    Last edited by Daniil; Oct 24, 2013 at 6:22 AM. Reason: Please use [CODE] tags
Page 1 of 2 12 LastLast

Similar Threads

  1. Save state of Locking GridPanel
    By sonnh11 in forum 1.x Help
    Replies: 0
    Last Post: May 25, 2012, 8:15 AM
  2. Replies: 2
    Last Post: Apr 07, 2012, 6:40 AM
  3. Save TreePanel state
    By Kaido in forum 1.x Help
    Replies: 0
    Last Post: Sep 16, 2009, 11:46 AM
  4. grid save and reload
    By [WP]joju in forum 1.x Help
    Replies: 2
    Last Post: Aug 10, 2009, 4:18 AM
  5. How to save the Portlet state/position
    By Neeraj Sharma in forum 1.x Help
    Replies: 5
    Last Post: Mar 04, 2009, 4:48 AM

Posting Permissions