PDA

View Full Version : store.getById only searching local data



cmeans
27 Jun 2014, 6:43 AM
ExtJS v4.1.3

I have a paged GridPanel, and I need to find (and highlight) an entry, that may not have been loaded yet. I do know that the Id exists in the store.

I've tried programmatically loadPage(store.currentPage + 1), until I find the record, but given that the calls are asynchronous, it's not working for me.

Any suggestions for a good/better approach to this?

Thanks.

-Chris

Farish
27 Jun 2014, 6:53 AM
you can add a listener 'on' load event and then when the event is fired, you can check if your record has been loaded or not. if not, you can load the next page. when you find the record, remove the listener using 'un'.


var totalCount = store_result.getTotalCount();
var pageCount = Math.ceil(totalCount / store_result.pageSize);
i = 1;

store.on('load', function() {
if(store.findRecord("id", id)) // if record is found, remove listener
store.un('load',arguments.callee);
else
{
if(i < pageCount)
{
i++;
store.loadPage(i);
}
}
});

cmeans
27 Jun 2014, 8:59 AM
Thanks, that's working well.