Content
• Store. getAt (...) And Store. getById (...)
• Store. getCount (...) And getTotalCount () and Store. each (...)
• Store. filter (...) And Store. filterBy (...)
• Store. find (...) And Store. findBy (...) And Store. findExact (...)
• Store. queryBy (...)
The Ext. Net Framework is an Ext JS encapsulated by. net. In the Ext. Net program, you can still use Ext JS to write scripts. Although development with Ext. Net is much more convenient and convenient than directly using Ext JS, for example, you can drag and drop the Ext. Net Control directly on the page ...... If you want to better use the Ext. Net Framework, it is necessary to write the Ext JS script in the program.
GridPanel flag
Assume that the page has an Ext. Net. Store and Ext. Net. GridPanel controls. The GridPanel controls are not paged and data has been loaded in the Page_Load event. Mark as follows:
<Ext: GridPanel ID = "GridPanel1" runat = "server" AutoHeight = "true" Width = "500" Title = "Plants">
<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>
In this case, you can use Ext JS to write scripts on the client to traverse, retrieve, and filter Ext. Net. Store files. Especially those with poor real-time performance, users only operate on their own data.
Store. getAt (...) And Store. getById (...)
GetAt (Number index): Ext. data. Model
GetById (String id): Ext. data. Model
Store. getAt (...) Method returns a Record based on the index.
Store. getById (...) The method returns a Record based on the Id you set in the Store. Here, Record is the script class. There are several buttons on the page. The demo is similar, as shown below:
<Div style = "float: left">
<Div>
<Ext: Button ID = "Button1" runat = "server" Icon = "Accept" Text = "demo 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' field" Text = "7">
</Ext: TextField>
</Div>
<Div style = "float: left">
<Ext: Button ID = "Button2" runat = "server" Icon = "Accept" Text = "demo store. getById">
<Listeners>
<Click Handler = "yourGetById (Store1, TextField1.getValue ();"/>
</Listeners>
</Ext: Button>
</Div>
</Div>
</Div>
The script is as follows:
<Script type = "text/javascript">
Var yourGetAt = function (store ){
Var vals = [];
For (var I = 0; I <store. getCount (); I ++ ){
Vals. push (store. getAt (I). data. Id + "-" + store. getAt (I). data. Common );
}
Ext.net. Notification. show ({
IconCls: 'icon-information ',
PinEvent: 'click ',
Height: 500,
Width: 500,
Html: vals. join (','),
Title: 'title'
});
};
Var yourGetById = function (store, getByIdValue ){
Var record = store. getById (getByIdValue );
Alert (record. data. Id + "" + record. data. Common );
}
</Script>
Store. getCount (...) And getTotalCount () and Store. each (...)
GetCount (): Number
Each (Function fn, [Object scope]): void
Store. getCount (...) You can obtain the number of cached records. If pagination is used, this quantity is not the total number of datasets. If the Reader data object contains the dataset size, the getTotalCount function returns the dataset size. That is to say, if pagination is used, the data size of the current page is returned by this method.
Store. each (...) Call the function you specified for each Record in the cache.
<Script type = "text/javascript">
Var yourGetCount = function (store ){
Var vals = [];
// For (var I = 0; I <store. getTotalCount (); I ++ ){
// Vals. push (store. getAt (I). data. Id + "-" + store. getAt (I). data. Common );
//}
For (var I = 0; I <store. getCount (); I ++ ){
Vals. push (store. getAt (I). data. Id + "-" + store. getAt (I). data. Common );
}
Ext.net. Notification. show ({
IconCls: 'icon-information ',
PinEvent: 'click ',
Height: 500,
Width: 500,
Html: vals. join (','),
Title: 'title'
});
};
Var yourEach = function (store ){
Var vals = [];
Store. each (function (r ){
Vals. push (r. data. Id + "-" + r. data. Common );
}, This );
Ext.net. Notification. show ({
IconCls: 'icon-information ',
PinEvent: 'click ',
Height: 500,
Width: 500,
Html: vals. join (','),
Title: 'title'
});
}
</Script>
Store. filter (...) And Store. filterBy (...)
Filter (Mixed filters, String value): void
FilterBy (Function fn, [Object scope]): void
Store. filter (...) Filter and load the dataset Based on the specified field.
Store. filterBy (...) Filter Based on the filter function. Each Record in the Store calls the filter function. If the function returns true, the Record is included; otherwise, the Record is filtered out.
<Script type = "text/javascript">
Var yourFilter = function (store, filterValue ){
Store. filter ('common', filterValue );
};
Var yourFilterBy = function (store, filterByValue ){
Store. filterBy (function (r ){
Return r. data. Light = filterByValue;
}, This );
}
</Script>
Store. find (...) And Store. findBy (...) And Store. findExact (...)
Find (String fieldName, String/RegExp value, [Number startIndex], [Boolean anyMatch], [Boolean caseSensitive], Boolean exactMatch): Number
FindBy (Function fn, [Object scope], [Number startIndex]): Number
FindExact (String fieldName, Mixed value, [Number startIndex]): Number
Store. find (...) Search for the index of the first matched Record in the Store using a specified field value.
Store. findBy (...) You can use a specified function to search for the index of the first matched Record in the Store. If the function is true, the Record is returned.
Store. findExact (...) Search for the index of the first matched Record in the Store using a specified field value.
<Script type = "text/javascript">
Var yourFind = function (store, findValue ){
Var index = store. find ('id', findValue, 0, true );
If (index <0)
Alert ('Not found .');
Else
Alert (store. getAt (index). data. Id + "" + store. getAt (index). data. Common );
};
Var yourFindBy = function (store, findByValue ){
Var index = store. findBy (function (r ){
Return r. data. Light = findByValue;
}, This, 0 );
If (index <0)
Alert ('Not found .');
Else
Alert (store. getAt (index). data. Id + "" + store. getAt (index). data. Common );
};
Var yourFindExact = function (store, findExactValue ){
Var index = store. findExact ('light ', findExactValue, 0 );
If (index <0)
Alert ('Not found .');
Else
Alert (store. getAt (index). data. Id + "" + store. getAt (index). data. Common );
}
</Script>
Store. queryBy (...)
QueryBy (Function fn, [Object scope]): MixedCollection
Use a filter function to search for cached Recors in the Store. Each Record in the Store calls the filter function. If this function returns true, the Record is included in the result.
Store. queryBy (...) And Store. find ***: the former returns a set, which is a script class. Unlike Records, the latter returns an index. The former returns the Record of all matching filtering functions, the latter only returns the first matched Record.
<Script type = "text/javascript">
Var yourQueryBy = function (store, queryByValue ){
Var records = store. queryBy (function (record ){
Return record. data. Light = queryByValue;
}, This );
If (records. length> 0 ){
Var vals = [];
Ext. each (records. items, function (r ){
Vals. push (r. data. Id + "-" + r. data. Common );
}, This );
Ext.net. Notification. show ({
IconCls: 'icon-information ',
PinEvent: 'click ',
Height: 500,
Width: 500,
Html: vals. join (','),
Title: 'title'
});
}
Else {
Alert ('Not found .');
}
};
</Script>
Download Demohttp: // www.bkjia.com/uploadfile/2012/0#/2012041091225414.rar
From the IGod Interface