Generic loadAllRemainingRecords()

Matt SonesMatt Sones 💎💎💎
edited October 15, 2019 in Ideas
A little adaptation of http://help.skuid.com/m/11720/l/205447-skuid-model-model#loadAllRemainingRecords

All this inline script to any page, and it will load all the records for the first model of the page and display the nice loading messages. This is handy if you have a list view page and want to load all the rows, but you want to do it in chunks to avoid heap size limits.

I made it generic so I could reuse the same static resource on multiple pages.
(function(skuid){
var $ = skuid.$;
$(document.body).one('pageload',function(){
      var model = skuid.model.list()[0];
$.blockUI({ message: 'Loading all available '+model.label+'...' });
      model.loadAllRemainingRecords({
         stepCallback: function(offsetStart,offsetEnd) {
            $.blockUI({ message: 'Loading ' + model.label + ' ' + offsetStart + ' to ' + offsetEnd + '...' });
         },
         finishCallback: function(totalRecordsRetrieved) {
            $.blockUI({ message: 'Finished loading all ' + totalRecordsRetrieved + ' ' + model.labelPlural +'!', timeout: 2000 });
         }
      });
});
})(skuid);
3
3 votes

Awaiting Review · Last Updated

Comments

  • edited October 15, 2019
    Nice
  • Karen WaldschmittKaren Waldschmitt 🛠️ 
    edited March 2, 2017
    Matt~

    Thanks for sharing this with the community!

    Karen
  • RoyRoy
    edited October 11, 2017
    hey Matt, thanks for this! is there a way to specify the load batch size for this? the initial limit on my model is 50 (total records are 2000+) when I do a loadAllRemainingRecords() I see that records are retrieved in batches for 50 again and this takes long, is there a way I can set the next batch size to 500? or does skuid determine that internally?
  • Matt SonesMatt Sones 💎💎💎
    edited October 11, 2017
    Royston,

    Not sure if this will work, but you could try setting
    model.recordsLimit = 500;
    before you load the remaining records.
  • RoyRoy
    edited October 11, 2017
    Hi Matt, that worked. I thought that would improve performance, but apparently 1 trip to get 500 records and  5 trips to get 100 records/trip amounts to the same. anyway thanks for your reply!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!