As far as I’m aware, there is a very helpful updateRows function that lets you update many rows at once in a model preventing screen rendering lag issues and in general is much more efficient than running through a loop of individual updateRow calls. Also as I understand it this more easily allows you to manage potentially asynchronous operations better by knowing when your update on all rows is complete ($when.done for updateRows runs after updating all rows, whereas $when.done for updateRow just happens on that individual row and it’s more difficult to figure out when you’ve completed updating all rows).
There doesn’t appear to be an equivalent createRows function, forcing you to run createRow in a loop which usually isn’t a problem but in some cases, particularly where a table for a given model has already (at some point) been rendered on the screen and you’re running through a loop of createRow, it can cause an incredible amount of lag / freezing of your page.
Is there indeed not an equivalent createRows function (similar to updateRows) that I’m missing? If not I’d highly recommend this as a very useful function to add to the API.
Thanks!
Possible documentation for createRows:createRows(inserts[, options])
Creates the given rows and fields, then notifies all registered UI elements that changes took place.
Changes made will not be sent to the server until the save( ) method is called.
Arguments:- inserts (object) – An array of row objects. Each row object is a map of field names to field values.
- options (object) –
OPTIONAL. A simple object map of additional settings to pass in to this method call. Supported options include:
- doAppend (boolean): Optional. By default,
createRows()will prepend created rows to the Model’s existing data rows. ifdoAppendis set to true, however, then the rows will be appended to the end of the model’s data rows. - editModeForNewItems (boolean): Optional, defaults to false. If true, then any skuid.ui.Items created in response to the creation of new rows will be placed into edit mode initially, rather than read mode.
- doAppend (boolean): Optional. By default,
The created row objects.
Return type:object
EXAMPLE:
Create new rows specifying their values in myModel:
var rowsToCreate = ;
for(i=0;i<100;i++){
rowsToCreate.push({Name: ‘New Name 1’, CustomField__c: ‘New Value 1’});
}
myModel.createRows( rowsToCreate );```