当前位置:编程学习 > JS >>

Ext.Net/Ext JS_Ext.Net.Store检索

本文内容
• Store.getAt(…) 和 Store.getById(…)
• Store.getCount(…) 和 getTotalCount() 以及 Store.each(…)
• Store.filter(…) 和 Store.filterBy(…)
• Store.find(…) 和 Store.findBy(…) 以及 Store.findExact(…)
• Store.queryBy(…)
 
Ext.Net 框架是用 .net 封装的 Ext JS。在 Ext.Net 程序中,仍然可以使用 Ext JS 写脚本。虽然用 Ext.Net 开发比直接用 Ext JS 方便、快捷很多,比如,你可以将 Ext.Net 控件直接拖放页面上……可若想更好地使用 Ext.Net 框架,能在程序中写 Ext JS 脚本很有必要。
 
GridPanel 标记
假设页面有个 Ext.Net.Store 和 Ext.Net.GridPanel 控件,其中 GridPanel 控件不分页,并且在 Page_Load 事件中已加载数据。标记如下:
<ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true" Width="500" Title="植物">
    <Store>
        <ext:Store ID="Store1" runat="server" OnRefreshData="MyRefreshData" GroupField="Light">
            <Reader>
                <ext:JsonReader IDProperty="Id">
                    <Fields>
                        <ext:RecordField Name="Id" />
                        <ext:RecordField Name="Common" />
                        <ext:RecordField Name="Botanical" />
                        <ext:RecordField Name="Zone" Type="Int" />
                        <ext:RecordField Name="ColorCode" />
                        <ext:RecordField Name="Light" />
                        <ext:RecordField Name="Price" Type="Float" />
                        <ext:RecordField Name="Availability" Type="Date" />
                        <ext:RecordField Name="Indoor" Type="Boolean" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
    </Store>
    <ColumnModel ID="ColumnModel1" runat="server">
        <Columns>
            <ext:Column Header="Key" DataIndex="Id" />
            <ext:Column Header="Common Name" DataIndex="Common" />
            <ext:Column Header="Light" DataIndex="Light" />
            <ext:Column Header="Price" DataIndex="Price" Align="right" Groupable="false" />
            <ext:Column Header="Price" DataIndex="Price" Align="right" Groupable="false" />
            <ext:DateColumn Header="Available" DataIndex="Availability" Groupable="false" Format="yyyy-MM-dd" />
        </Columns>
    </ColumnModel>
    <SelectionModel>
        <ext:RowSelectionModel ID="RowSelectionModel1" runat="server">
        </ext:RowSelectionModel>
    </SelectionModel>
    <View>
        <ext:GroupingView ID="GroupingView1" runat="server" ForceFit="true" />
    </View>
</ext:GridPanel>

 



那么在客户端用 Ext JS 编写脚本,遍历、检索、过滤 Ext.Net.Store 将很有用。尤其是那些实时性不强,用户只操作自己的数据。
 
Store.getAt(…) 和 Store.getById(…)
getAt( Number index ) : Ext.data.Model
getById( String id ) : Ext.data.Model
Store.getAt(…) 方法根据索引返回 Record。
Store.getById(…) 方法根据你在 Store 中设置的 Id 返回 Record。其中,Record 是脚本类。页面放几个按钮,后边的演示类似,如下所示:
<div style="float: left">
    <div>
        <ext:Button ID="Button1" runat="server" Icon="Accept" Text="演示 store.getAt">
            <Listeners>
                <Click Handler="yourGetAt(Store1);" />
            </Listeners>
        </ext:Button>
    </div>
    <br />
    <div>
        <div style="float: left">
            <ext:TextField ID="TextField1" runat="server" FieldLabel="'Id' 字段" Text="7">
            </ext:TextField>
        </div>
        <div style="float: left">
            <ext:Button ID="Button2" runat="server" Icon="Accept" Text="演示 store.getById">
                <Listeners>
 &
补充:Web开发 , ASP.Net ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,