Generic loadAllRemainingRecords()

  • 3
  • Idea
  • Updated 1 year ago
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);
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 3 years ago

  • 3
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
Nice
Photo of Karen Waldschmitt

Karen Waldschmitt, Official Rep

  • 8,240 Points 5k badge 2x thumb
Matt~

Thanks for sharing this with the community!

Karen
Photo of Royston Goveia

Royston Goveia

  • 424 Points 250 badge 2x thumb
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?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Royston,

Not sure if this will work, but you could try setting
model.recordsLimit = 500;
before you load the remaining records.
Photo of Royston Goveia

Royston Goveia

  • 424 Points 250 badge 2x thumb
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!