1
votes

So say I have a store and that in my DB I have 20,000,000 rows. (aka enough so that I have setup pagesize so that I only get back 100 rows per page). Since I have pagesize set, when I do the original call I only get 100 items back. Thus the following returns null:

Ext.getStore('MyLargeStore').getById(200); // returns null

This makes sense to me since technically the store in the JS side doesn't have that particular id set. But is there anyway to do a force lookup if that id doesn't exist? From what I can tell I've already done everything 'remote' and 'auto' that needs it in my store:

Ext.define('MyApp.store.MyLargeStore', {
extend: 'Ext.data.Store',

requires: [
    'MyApp.model.MyLargeModel'
],

constructor: function(cfg) {
    var me = this;
    cfg = cfg || {};
    me.callParent([Ext.apply({
        autoLoad: true,
        autoSync: true,
        model: 'MyApp.model.MyLargeModel',
        remoteFilter: true,
        remoteSort: true,
        storeId: 'MyLargeModel',
        buffered: true,
        pageSize: 100
    }, cfg)]);
}
});

Is there anyway to make it pull from the remote server whenever an id doesn't exist? I can't seem to find a method in the docs (unless I'm missing it since their docs are a little hard to decipher sometimes =/)

Also, I assume you can always do a load on the store, but I'm pretty sure if I load just that 1 row then all other locations where that store is being used will also only have that row (which I don't necessarily want) So theoretically would creating a store on the fly be my only option? Seems like there should be an easier way hence why I figured I'd ask. there must be some better way rather than creating a store and then grabbing the record from that new store...

1

1 Answers

1
votes

What your trying to do here is the wrong approach to the problem. You need to step back to what you need this row for and make an independent ajax call to your server with the ID of the row your trying to look up. The server will then look up that single row on the DB and then return the data to create a model for whatever you need the row for. This logic should be done independent of the store.