0

http://examples.ext.net/#/GridPanel/Paging_and_Sorting/XML_WebService/ 我只是在这个例子中添加了一个 ext:GridFilters 。这就是全部。我用 ext:GridFilters 测试了这个例子,但没有给我过滤的数据。

这是aspx代码;

<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>

我在网络服务上调用这个方法,

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

}

但过滤器变空。

4

1 回答 1

1

Local="false" 的 GridFilters 会自动发送过滤器的值。您不需要放入 StoreParameter。

参数名称默认为“filter”。但是,下面的签名

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

可能会导致初始加载请求出现问题,因为 GridFilters 发送仅​​在应用任何过滤器时才会添加过滤器参数。因此,如果没有过滤器参数,WebService 将抛出错误。

所以,我可以推荐你使用 StoreRequestParameters 类。

[WebMethod]
public Paging<SomeEntity> GetData()
{
    StoreRequestParameters parameters = new StoreRequestParameters(this.Context);
    return new Paging<SomeEntity>(...);
}
于 2013-08-01T09:00:04.613 回答