Question

http://examples.ext.net/#/GridPanel/Paging_and_Sorting/XML_WebService/ I just add this example a ext:GridFilters .thats all.I test ed this example with ext:GridFilters ,but didt give me filtered data.

here is the aspx code ;

<html>
    <body>
        <form id="form1" runat="server">

            <ext:ResourceManager ID="ResourceManager1" runat="server" />

            <ext:GridPanel 
                runat="server" 
                ID="GridPanel1" 
                Title="Employees" 
                Frame="true" 
                Height="300">
                <Store>
                    <ext:Store 
                        ID="Store1" 
                        runat="server" 
                        RemoteSort="true" 
                        RemoteFilter="true"
                        AutoSync="false" RemotePaging="true"
                        PageSize="5">
                        <Proxy>
                            <ext:AjaxProxy Url="WebService1.asmx/PlantsPaging">
                                <ActionMethods Read="GET" />
                                <Reader>
                                    <ext:XmlReader Record="Plant" TotalProperty="TotalRecords" />
                                </Reader>
                            </ext:AjaxProxy>
                        </Proxy>
                        <Parameters>
                            <ext:StoreParameter Name="filter" Value="" Mode="Value" />
                        </Parameters>
                        <Model>
                            <ext:Model ID="Model1" runat="server">
                                <Fields>
                                    <ext:ModelField Name="Common" />
                                    <ext:ModelField Name="Botanical" />
                                    <ext:ModelField Name="Light" />
                                    <ext:ModelField Name="Price" Type="Float" />
                                    <ext:ModelField Name="Availability" Type="Date" />
                                    <ext:ModelField Name="Indoor" Type="Boolean" />
                                </Fields>
                            </ext:Model>
                        </Model>
                        <Sorters>
                            <ext:DataSorter Property="Common" Direction="ASC" />
                        </Sorters>
                    </ext:Store>
                </Store>
                        <Features>
                                <ext:GridFilters ID="GridFilters1" runat="server" Local="false" >
                                    <Filters>
                                         <ext:StringFilter DataIndex="Common" />
                                        <ext:StringFilter DataIndex="Botanical" />


                                    </Filters>
                                </ext:GridFilters>
                            </Features>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ID="Column1" runat="server" Text="Common Name" DataIndex="Common" Sortable="true" Flex="1"  />
                        <ext:Column ID="Column2" runat="server" Text="Botanical" DataIndex="Botanical" Width="230" />
                        <ext:Column ID="Column3" runat="server" Text="Light" DataIndex="Light" Width="130" />
                        <ext:Column ID="Column4" runat="server" Text="Price" DataIndex="Price" Width="70" Align="right" />
                        <ext:DateColumn ID="DateColumn1" runat="server" Text="Available" DataIndex="Availability" Width="95" Format="yyyy-MM-dd" />
                        <ext:Column ID="Column5" runat="server" Text="Indoor?" DataIndex="Indoor" Width="55" />
                    </Columns>
                </ColumnModel>
                <View>
                    <ext:GridView ID="GridView1" runat="server" LoadingText="Loading XML..." />
                </View>          
                <BottomBar>
                    <ext:PagingToolbar ID="PagingToolbar1"
                        runat="server"                     
                        DisplayInfo="true" 
                        DisplayMsg="Displaying plants {0} - {1} of {2}" 
                        EmptyMsg="No plants to display" 
                        />
                </BottomBar>
            </ext:GridPanel>
        </form>

    </body>
    </html>

I am calling this method on web service,

 public Paging<Plant> PlantsPaging(int start, int limit, string sort, string filter)
        {

}

but filter get empty.

Was it helpful?

Solution

A GridFilters with Local="false" sends the filters' values automatically. You do not need to put in into a StoreParameter.

The parameter name is "filter" by default. However, the following signature

[WebMethod]
public Paging<SomeEntity> GetData(int start, int limit, string sort, string filter) 

can cause a problem for an initial load request, because a GridFilters sends adds a filter parameter only if any filter is applied. So, if no filter parameter, a WebService will throw an error.

So, I can recommend you to use the StoreRequestParameters class.

[WebMethod]
public Paging<SomeEntity> GetData()
{
    StoreRequestParameters parameters = new StoreRequestParameters(this.Context);
    return new Paging<SomeEntity>(...);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top