EXTJS 4.2 资料 控件之 Store 用法
最近工作,发现在Extjs中自定义Store的功能挺多,特意在此做笔记,几下来,具体代码如下:
1.定义Store
//定义Store var ItemSelectorStore = new Ext.data.ArrayStore({ fields: [ { name: 'BaseInfoId' }, { name: 'Title' } ] });
2.根据Grid的数据,循环往Store里面插
var selectedData = InfoCollectionGrid.getSelectionModel().getSelection(); if (selectedData.length < 1) { Ext.MessageBox.alert('提示', '请选择要批量移动的记录!'); return; } else { ItemSelectorFormWin_Move.show(); ItemSelectorFormWin_Move.setTitle("批量移动"); ItemSelectorStore.removeAll(); ItemSelectorStore_MoveDele.removeAll(); for (var i = 0; i < selectedData.length; i++) { ItemSelectorStore.insert(i, { InfoCollectionId: selectedData[i].data.InfoCollectionId, Title: selectedData[i].data.Title });//插入到最后一行 ItemSelectorStore_MoveDele.insert(i, { InfoCollectionId: selectedData[i].data.InfoCollectionId });//插入到最后一行 } document.getElementById('howMany_Move').innerText = "共选择了" + selectedData.length + "篇文章"; }
3.循环读取Store中某行某列的数据
for (var i = 0; i < ItemSelectorStore.getCount() ; i++) { var record = ItemSelectorStore.getAt(i); StrBaseInfoId += record.get("BaseInfoId") + ','; }
上面这是获取的是列:BaseInfoId的数据。
4.移除grid中某行的数据(静态删除数据)
FunctionActionDelete_StyleFiles = function () { if (gridJSFiles.getSelectionModel().getSelection()[0] == null) { Ext.MessageBox.alert('提示', '请选择要删除的记录吗!'); return; } var selectedData = gridJSFiles.getSelectionModel().getSelection()[0].data; Ext.Msg.confirm("提示!", "确定要删除的记录吗?", function (btn) { if (btn == "yes") { var sm = gridJSFiles.getSelectionModel(); var store = gridJSFiles.getStore(); store.remove(sm.getSelection()); if (store.getCount() > 0) { sm.select(0); } } else { return; } }); }
5.移除grid中某行的数据(动态删除数据)
FunctionActionDelete = function () { if (grid.getSelectionModel().getSelection()[0] == null) { Ext.MessageBox.alert('提示', '请选择要删除的记录吗!'); return; } var selectedData = grid.getSelectionModel().getSelection()[0].data; Ext.Msg.confirm("提示!", "确定要删除的记录吗?", function (btn) { if (btn == "yes") { Ext.MessageBox.show({ msg: '正在删除,请稍等...', progressText: 'Saving...', width: 300, wait: true, waitConfig: { interval: 200 } }); setTimeout(function () { }, 1000); Ext.Ajax.request({ url: '/UI/HttpHandlerData/JDQP/JDQP.ashx?operation=DeleCarPartsType', method: "POST", params: { CSId: selectedData.CSId }, success: function (response) { Ext.MessageBox.alert('提示', '删除成功!'); store.load({ params: { start: start, limit: limit } }); Ext.MessageBox.hide(); }, failure: function (errorInfo) { Ext.MessageBox.alert("提示", "删除失败!<br>" + errorInfo.responseText); } }); } }); }
我的小鱼你醒了,
还认识早晨吗?
昨夜你曾经说,
愿夜幕永不开启。
初吻吻别的那个季节,
不是已经哭过了吗?
你的香腮边轻轻滑落的,
是你的泪,还是我的泪。
我的指尖还记忆著,
你慌乱的心跳。
温润的体香里,
那一缕长髮飘飘。
——青青树 《魁拔》
交流群:ASP.NET交流群(2群) 58189568
ExtJs4.2交流群(3群)97869295
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决