SMART datagrid v.1 > Classes > GridDataSet
Update the values of data row which matches the condition specified by parameter where with the values transferred by newValues.
where can be Expression string or callback function. newValues is JSON object of containing the fields which would be changed. In the value of each field, it can specify callback function which returns field value.
If checkDiff is true, it will update the row only when one or more field values are different by comparing the value of newValues with the existing field value. If strictDiff is true, it will compare with DataField.equalValues, sameValues. If noState is true, it will not change the state of data rows.
Variable | Explanation |
---|---|
'row' | The index of data row. |
'values' | The value of field. 'values[field]'. The field can be specified by field index or field name. |
'state' | The State of data row. CREATED is 'c', UPDATED is 'u', DELETED is 'd' CREATE_AND_DELETED is 'x'. |
// Transfer the discriminant to where.
dataset.updateValues(
"values['flow'] == 'import'", // where
{ amount: 100, active: false }, // newValues
false, false, false);
}
// Specify callback in where.
dataset.updateValues(
function (ds, row, values) { // where
retrun values[0] == 'import';
},
{ amount: 100, active: false }, // newValues
false, false, false);
}
// Transfer the discriminant to field value.
dataset.updateValues(
"values['flow'] == 'import'", // where
{ // newValues
amount: 100,
active: function (ds, row, field) {
if (ds.getValue(row, 0) == 'import') {
return true;
}
return false;
}
},
false, false, false);
}