标签:
最近工作,发现在Extjs中自定义Store的功能挺多,特意在此做笔记,几下来,具体代码如下:
1.定义Store
//定义Store var ItemSelectorStore = new Ext.data.ArrayStore({ fields: [ { name: ‘BaseInfoId‘ }, { name: ‘Title‘ } ] });
2.根据Grid的数据,循环往Store里面插
var rows = grid.getSelectionModel().getSelections(); if (rows.length < 1) { Ext.MessageBox.alert(‘提示‘, ‘请选择要删除的记录!‘); return; } else { EditItemSelectorFormWin_Dele.show(); Ext.getCmp("EditItemSelectorFormWin_Dele").setTitle("批量删除"); ItemSelectorStore.removeAll(); for (var i = 0; i < rows.length; i++) { ItemSelectorStore.insert(i, new ItemSelectorStore.recordType({ BaseInfoId: rows[i].get("BaseInfoId"), Title: rows[i].get("Title") }));//插入到最后一行 } document.getElementById(‘howMany_Dele‘).innerText = "您将要删除以下" + rows.length + "篇文章"; }
3.循环读取Store中某行某列的数据
for (var i = 0; i < ItemSelectorStore.getCount() ; i++) { var record = ItemSelectorStore.getAt(i); StrBaseInfoId += record.get("BaseInfoId") + ‘,‘; }
上面这是获取的是列:BaseInfoId的数据。
标签:
原文地址:http://www.cnblogs.com/foreverfendou/p/4192877.html