[OPEN] [#110] GridFilters Plugin MVC

Page 1 of 2 12 LastLast
  1. #1

    [OPEN] [#110] GridFilters Plugin MVC

    Hi,

    The filter parameters are not being passed to my controller as expected.

    Filter Configuration in markup
    
                        <ext:GridFilters runat="server"  ID="gridFiltersGridView"  AutoDataBind="true">
                            <Filters>
                            </Filters>
                        </ext:GridFilters>
    i am adding the filters dynamically.

    Controller
    public StoreResult GetCustomerList(int limit, int start, string dir, string sort, string filter){
    
    }
    The filter value is not being passed back to the controller.

    Please let me know if i may be missing anything.
    Last edited by Daniil; Dec 29, 2012 at 9:16 AM. Reason: [OPEN] [#110]
  2. #2
    Hi,

    Does explicitly setting
    Local="false"
    for the GridFilters help?

    The answers on the following questions can help us to narrow the problem.

    How is the Store configured? In particular, is it configured with an AjaxProxy?

    If no, how do you initiate a load request?
  3. #3
    Hi,

    See my store settings below. Setting the Local = "false" does not make a difference.


    return Ext.create('Ext.data.JsonStore', {
                remoteSort: true,
                remoteFilter: true,
                buffered: true,
                fields: fields,
                autoLoad: false,
                pageSize: model.Grid.DefaultPageSize,
                showWarningOnFailure: true,
                proxy: {
                    type: "ajax",
                    url: "/ResultsManagement/GridView/GetResultSetPage",
                    reader: {
                        root: "data",
                        type: "json",
                        totalProperty: 'total'
                    },
                   
                    filterParam: "Filter",
                    groupParam: "Group",
                    limitParam: "Limit",
                    pageParam: "PageIndex",
                    directionParam: "SortDirection",
                    sortParam: "Sort",
                    startParam: "Start",
                    listeners: {
                        exception: { fn: function (el, response, operation, eOpts) {
    
                            alert(response.text);
    
                        }
                        }//end exception
                    }
                },
            listeners: {
                beforeload: { fn: function (store, operation, eOpts) {
    
                   
    
                }
                }//end exception
            }
            });
    for initial load request i use:

    store.loadPage(1);
    All other requests as buffered.
  4. #4
    It seems there is a bug.

    If you would remove the beforeload listener, are the things going well?
  5. #5
    Hi,

    Everything works well after removing the listener but the filter is still not passed to the controller. Is there anything else that I can try?
  6. #6
    Quote Originally Posted by RCM View Post
    the filter is still not passed to the controller. Is there anything else that I can try?
    Can you use the "filter" parameter in a load request? Is it initial load request or when you apply some filter?

    Could you, please, provide a full sample to reproduce?
  7. #7
    Quote Originally Posted by Daniil View Post
    It seems there is a bug.

    If you would remove the beforeload listener, are the things going well?
    I investigated, there is no bug with BeforeLoad listener.
  8. #8
    Hi,

    Please see my sample below.


    Controller
    
        public class GridController : Controller
        {
            //
            // GET: /Grid/
    
            public ActionResult Index()
            {
                return View();
            }
    
    
            public StoreResult GetData(int start, int limit, int page, string filters)
            {
                StoreResult response = new StoreResult();
    
                List<User> data = new List<User>();
    
                Random randow = new Random();
                DateTime now = DateTime.Now;
    
                for (int i = start + 1; i <= start + limit; i++)
                {
                    User user = new User()
                    {
                        Firstname = "User " + i,
                        Lastname = "User Last " + i,
                    };
    
                    data.Add(user);
                }
    
                response.Data = data;
                response.Total = 3000;
    
                return response;
            }
    
        }
    
        public class User
        {
            public String Firstname { get; set; }
    
            public String Lastname { get; set; }
        }

    JS 
    
    GridView = {
    
        InitializeView: function () {
    
            GridView.ReconfigureGrid();
        },
    
    
        ReconfigureGrid: function () {
            var columns = [{ text: 'First Name', dataIndex: 'Firstname' }, { text: 'Last Name', dataIndex: 'Lastname'}];
            var fields = [{ name: 'Firstname', type: 'string' }, { name: 'Lastname', type: 'string'}];
    
    
    
            var grid = App.gridPanelGridView;
    
            var store = grid.store;
            var oldStore = store;
    
            store.removeAll();
            store = GridView.CreateStore(fields);
    
            grid.reconfigure(store, columns);
    
            GridView.SetGridFilters(fields, columns);
            store.loadPage(1);
            oldStore.destroy();
        },
    
    
    
        CreateStore: function (fields) {
    
            return Ext.create('Ext.data.JsonStore', {
                remoteSort: true,
                remoteFilter: true,
                buffered: true,
                fields: fields,
                autoLoad: false,
                pageSize: 500,
                showWarningOnFailure: true,
                proxy: {
                    type: "ajax",
                    url: "/Grid/GetData",
                    reader: {
                        root: "data",
                        type: "json",
                        totalProperty: 'total'
                    },
                    listeners: {
                        exception: { fn: function (el, response, operation, eOpts) {
    
                            alert(response.text);
    
                        }
                        }//end exception
                    }
                },
                listeners: {
                }
            });
        },
    
        SetGridFilters: function (fields, columns) {
            App.gridPanelGridView.filters.clearFilters();
            for (var i = 0; i < columns.length; i++) {
                for (var j = 0; j < fields.length; j++) {
                    if (columns[i].dataIndex == fields[j].name) {
                        App.gridPanelGridView.filters.addFilter({ dataIndex: columns[i].dataIndex, type: fields[j].type });
                        break;
                    }
                }
            }
        }
    }
    View
    
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
        <meta content="NO-CACHE" http-equiv="CACHE-CONTROL" />
        <%-- Override the default label seperator and set to ""--%>
        <ext:ResourcePlaceHolder runat="server" Mode="ScriptFiles" />
        <script type="text/javascript">
            Ext.Component.prototype.labelSeparator = "";
        </script>
        <script src="/Scripts/GridView.js" type="text/javascript"></script>
        <style type="text/css">
            .Header
            {
                font: 12px helvetica,arial,sans-serif;
            }
            .list-over
            {
                background-color: white;
            }
            
            .my-listview .x-list-body dt
            {
                white-space: normal;
                cursor: arrow;
            }
        </style>
        <script type="text/javascript">
            var formatDate = function (v) {
                return value.format(Common.GetJSDateFormat());
            };
        </script>
    </head>
    <body>
        <ext:ResourceManager runat="server">
            <Listeners>
                
            </Listeners>
        </ext:ResourceManager>
        <ext:Viewport ID="viewportResultView" runat="server" Layout="FitLayout" IDMode="Static">
            <Items>
                <ext:GridPanel ID="gridPanelGridView" runat="server" Region="Center">
                    <TopBar>
                    </TopBar>
                    <SelectionModel>
                        <ext:RowSelectionModel runat="server" PruneRemoved="false" Mode="Multi" />
                    </SelectionModel>
                    <ColumnModel>
                        <Columns>
                            <ext:RowNumbererColumn runat="server" Width="50" Sortable="false" />
                        </Columns>
                        <Listeners>
                        </Listeners>
                    </ColumnModel>
                    <Store>
                        <ext:Store runat="server" Buffered="true" PageSize="5">
                            <Model>
                                <ext:Model runat="server">
                                    <Fields>
                                        <ext:ModelField Name="dummy" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <Features>
                        <ext:GridFilters runat="server" ID="gridFiltersGridView" Local="false" MenuFilterText="temp"
                            AutoDataBind="true">
                            <Filters>
                                <ext:BooleanFilter />
                            </Filters>
                        </ext:GridFilters>
                    </Features>
                    <Listeners>
                        <CellDblClick Fn="" />
                        <ContainerContextMenu Fn="" />
                        <ViewReady  Handler="GridView.InitializeView();" />
                    </Listeners>
                </ext:GridPanel>
            </Items>
            <Listeners>
                <Render />
            </Listeners>
        </ext:Viewport>
    </body>
    </html>
  9. #9
    Thank you for the sample.

    FiltersFeature doesn't know about reconfiguring.

    You should bind a new store manually calling the bindStore method.
    filtersFeature.bindStore(newStore);
    http://docs.sencha.com/ext-js/4-1/#!...thod-bindStore
  10. #10
    Hi,
    Thanks and please mark as closed.
Page 1 of 2 12 LastLast

Similar Threads

  1. GridFilters plugin not displaying
    By Skizzot223 in forum 1.x Help
    Replies: 1
    Last Post: Apr 11, 2012, 12:49 PM
  2. Replies: 1
    Last Post: Oct 14, 2011, 3:53 PM
  3. Replies: 1
    Last Post: Sep 05, 2011, 5:52 AM
  4. [CLOSED] GridFilters Plugin and MVC
    By Stefanaccio in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: Jan 06, 2011, 3:23 PM
  5. [CLOSED] GridFilters plugin with HttpProxy
    By tdracz in forum 1.x Legacy Premium Help
    Replies: 13
    Last Post: Oct 07, 2009, 7:25 AM

Posting Permissions