[CLOSED] GridFilters Plugin and MVC

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] GridFilters Plugin and MVC



    Hello,

    in an MVC application I'm using a GridPanel with the GridFilters Plugin. The GridPanel is linked to the following Store:

            <ext:Store ID="dsCustomers" runat="server" RemoteSort="true" >
                <Proxy>
                    <ext:HttpProxy Url="/Customer/GetCustomerList/" />
                </Proxy>
                <UpdateProxy>
                    <ext:HttpWriteProxy Url="/Customer/SaveCustomerList/" />
                </UpdateProxy>
                <Reader>
                    <ext:JsonReader IDProperty="CustomerId" Root="data" TotalProperty="total">
                        <Fields>
                            <ext:RecordField Name="CustomerId" Type="Int" />
                            <ext:RecordField Name="CustomerName" SortDir="ASC" />
                            <ext:RecordField Name="EMailAddress" />
                        </Fields>
                    </ext:JsonReader>
                </Reader>
                <BaseParams>
                    <ext:Parameter Name="limit" Value="50" Mode="Raw" />
                    <ext:Parameter Name="start" Value="0" Mode="Raw" />
                    <ext:Parameter Name="dir" Value="ASC" />
                    <ext:Parameter Name="sort" Value="CustomerName" />
                </BaseParams>
                <SortInfo Field="CustomerName" Direction="ASC" />
            </ext:Store>
    The Proxy invokes the following method in the CustomerController class:

    public AjaxStoreResult GetCustomerList(int limit, int start, string dir, string sort)
    {
        var query = (from c in this._CustomerRepository
                                     select new
                                     {
                                         c.CustomerId,
                                         c.CustomerName,
                                         c.EMailAddress
                                     }).OrderBy(string.Concat(sort, " ", dir));
    
    
        int total = query.Count();
        var paginatedQuery = query.Skip(start).Take(limit).ToList();
        return new AjaxStoreResult(paginatedQuery, total);
    }
    How can I pass filters set in the grid to the GetCustomerList method to parse them and send appropriate query to the database?

    Thanks,
    Stefano
  2. #2

    RE: [CLOSED] GridFilters Plugin and MVC

    Hi,

    Please update from SVN first


    You have to use Remote mode for GridFilters (by default)
    If you use remote mode then current filters set will be submitted as 'gridfilters'


    Action method:
    public AjaxStoreResult GetCustomerList(int limit, int start, string dir, string sort, string gridfilters)
            {
                if (!string.IsNullOrEmpty(gridfilters))
                {
                    FilterConditions filters = new FilterConditions(gridfilters);
                }
                return new AjaxStoreResult(data, total);
            }

    The example how to work with FilterConditions class
    https://examples1.ext.net/#/GridPane...ilters_Remote/

  3. #3

    RE: [CLOSED] GridFilters Plugin and MVC

    Hi,

    I tried your changes but there is something that I can not understand. When invoked the GetCustomerList method gridfilters string parameter has the value "[object Object]".

    Is there anything else I have to do?

    Bye,
    Stefano

  4. #4

    RE: [CLOSED] GridFilters Plugin and MVC

    Hi,

    Did you update from SVN?
  5. #5

    RE: [CLOSED] GridFilters Plugin and MVC

    Yes, this morning.

    Bye,
    Stefano
  6. #6

    RE: [CLOSED] GridFilters Plugin and MVC

    Hi,

    I think you still use old assemblies (may be caching issue)
    "[object Object]" is old behaviour, now gridfilters return json string
    Check assembly time creation
    If you sure that you use latest assemblies then please send me your test project with assemblies (support@object.net)
  7. #7

    RE: [CLOSED] GridFilters Plugin and MVC

    It's correct that after the SVN update I have to recompile the Ext.Net.install solution?

    Bye,
    Stefano
  8. #8

    RE: [CLOSED] GridFilters Plugin and MVC

    Hi,

    You have to recompile Ext.Net or Ext.Net.install solution (just install solution doesn't have Ext.Net.Examples, sandbox and another none required solutions).


    After recompile you have to add references on new assemblies in your application
  9. #9

    RE: [CLOSED] GridFilters Plugin and MVC

    It's all OK.

    Thanks,
    Stefano
  10. #10

    A sample Code for using FilterConditions within linq to sql model

    Action method:
    public AjaxStoreResult GetCustomerList(int limit, int start, string dir, string sort, string gridfilters)
            {
                if (!string.IsNullOrEmpty(gridfilters))
                {
                    FilterConditions filters = new FilterConditions(gridfilters);
                }
                return new AjaxStoreResult(data, total);
            }
    For the moment I cannot buy premium service (sorry) so if it possible could you post a sample of code that manages this gridfilters based on linq to sql model (below)
    public AjaxStoreResult GetCustomerList(int limit, int start, string dir, string sort)
    {
        var query = (from c in this._CustomerRepository
                                     select new
                                     {
                                         c.CustomerId,
                                         c.CustomerName,
                                         c.EMailAddress
                                     }).OrderBy(string.Concat(sort, " ", dir));
     
     
        int total = query.Count();
        var paginatedQuery = query.Skip(start).Take(limit).ToList();
        return new AjaxStoreResult(paginatedQuery, total);
    }
    In any case thank you anyway.
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. [CLOSED] Remote Filtering through Plugin 'GridFilters' with MVC
    By jesperhp in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 01, 2011, 3:10 PM
  3. Replies: 1
    Last Post: Oct 14, 2011, 3:53 PM
  4. [CLOSED] GridFilters plugin with HttpProxy
    By tdracz in forum 1.x Legacy Premium Help
    Replies: 13
    Last Post: Oct 07, 2009, 7:25 AM
  5. [CLOSED] AjaxEvent add filter to GridFilters plugin
    By methode in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 09, 2009, 12:14 PM

Tags for this Thread

Posting Permissions