May 06, 2010, 11:18 AM
[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