|
jr_add_subtable_row(string subtableViewName, mixed rows, boolean ignoreMaxRows, function finishCallback) |
Scroll Prev Top Next More |
This function adds one or more rows to a subtable view.
Parameter |
Type |
Description |
|---|---|---|
subtableViewName |
string |
Name of subtable view |
rows |
int | object | array |
int: Number of rows to be added to the view object: JavaScript object with the values for a single row array: Array with JavaScript objects, each of them with the values for a single row |
ignoreMaxRows (optional) |
boolean |
This parameter can be used to disable the check for the maximum number of rows. By default, the validation is enabled (false). |
finishCallback (optional) |
function |
Callback function that will be executed once after adding all rows. The number of successfully added rows are passed to it as parameter. |
This function does not return a value.
If the subtable view contains a callback function Before Add, it will be called up each time before a line is added.
If the subtable view contains a callback function After Add, it will be called up each time after a line was added.
Please note: This function performs an AJAX request. Due to this, the function can not be executed multiple times in a row, e.g. in a loop and you always have to wait for the previous AJAX request to complete prior to the next execution.
Example 1: Add an empty row with callback function
var myFinishCallback = function(addedRows) {
console.log(addedRows);
}
jr_add_subtable_row('mySubtableView', 1, false, myFinishCallback);
Example 2: Add a row with data
jr_add_subtable_row('mySubtableView', {
company: 'Acme Ltd.',
city: 'London'
});
Example 3: Add more rows with an array
jr_add_subtable_row('mySubtableView', [
{
company: 'Acme Ltd.',
city: 'London'
},
{
company: 'JobRouter AG',
city: 'Mannheim'
}
]);