ITKeyword,专注技术干货聚合推荐

注册 | 登录

解决javascript - Extjs get all store records

itPublisher 分享于

2020腾讯云10周年活动,优惠非常大!(领取2860元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1040

2020阿里云最低价产品入口,含代金券(新老用户有优惠),
地址https://www.aliyun.com/minisite/goods

推荐:Extjs中store的filter和filterBy的用法

在Extjs设计界面,很多时候并不需要将所有的数据都显示到界面上,这样子我们可以通过在创建store时添加filter属性或调用filterBy方法实现。 1、设计时设置filter

I have one question. Is it possible to get all records which are loaded in a store when the filters are being added to store? For example, if I load into the store 34 records and then apply filters and there is only 15 left, could I get those 34 records without clearing filters?

javascript extjs filter store
|
  this question
edited Oct 29 '14 at 14:41 HDave 10.4k 20 109 203 asked Sep 6 '13 at 12:39 kuldarim 596 5 15 37

 | 

3 Answers
3

解决方法

The whole loaded dataset is stored in the snapshot property of the store.

It is only created when needed though. That means that the property won't be available before some filters have been applied to the store. So to get the information you want in a safe way, use:

var allRecords = store.snapshot || store.data;

|
  this answer
answered Sep 6 '13 at 12:50 rixo 11.4k 1 15 29      yes i have just found out it myself. Thanks –  kuldarim Sep 6 '13 at 12:52      I don't understand why its so hard for Sencha to put a getAllRecords() method on the store. This seems non-intuitive –  Oliver Watkins Nov 18 '14 at 14:49      Yes... I think that's the kind of issue they're trying to address with the addition of chained stores in Ext 5. –  rixo Nov 19 '14 at 0:55

 | 

Perhaps a more forward compatible approach (i.e. ExtJS version >= 5) is the following:

var allRecords = store.getData().getSource().getRange();

Based on the documentaion, this should work for versions >= 5.0.

推荐:ExtJS中get、getDom、getCmp、getBody、getDoc使用 javascript[转]

getDoc = function(){ return Ext.get(document); }  Ext中包含了几个以get开头的方法,这些方法可以用来得到文档中DOM、得到当前文档中的组件、得到Ext元素等,


|
  this answer
answered Jul 9 '15 at 15:52 Mike Kelly 61 1 2      On Ext5, the store.getData().getSource() doesn't always exist... –  Klodoma Feb 2 '16 at 12:56 1   In 6.0.2, I just use: var recs = store.getRange(); –  Jess Apr 11 '16 at 19:49      store.getRange(); returns only filtered records –  Guid Mar 8 at 16:18

 | 

For getting all unfiltered data from a loaded store you can try var records = store.getUnfiltered();

Note: I am using Ext Js 5.1. Not sure about earlier versions.


|
  this answer
answered Jun 16 '15 at 11:04 Sikandar 80 1 6

 | 

推荐:ExtJS中get、getDom、getCmp、getBody、getDoc使用 javascript[转] .

Ext中包含了几个以get开头的方法,这些方法可以用来得到文档中DOM、得到当前文档中的组件、得到Ext元素等,在使用中要注意区别使用。 1、get方法 get方法用来得


相关阅读排行


相关内容推荐

最新文章

×

×

请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。

您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱

如果您没有收到激活邮件,请注意检查垃圾箱。