SMART datagrid v.1 > Classes > GridDataSet
DataLudi.GridDataSet.getModifiedRowObjects method
Return the changed row of which DataRowState is not NONE as JSON object array.
function getModifiedRowObjects (states: String|[String], valueCallback: Function, stateProp: String, stateNames: Object|[String], emptyValue: *): [Object];
- Returns
- [Object]
- Parameters
- states - String|[String].
DataRowState state list.
It specifies only one state or specify several states as array.
If do not specify, it will return all rows of which states are not
NONE.
- valueCallback - Function.
Callback function which will replace the original field value.
function (ds: GridDataSet, row: Integer, rowObj: Object);
- stateProp - String. Defaults to ""row_state"".
The property name which specifies the state value.
If specify as null or undefined, it will use the default value "row_state".
If it is an empty string, this property will not be added.
- stateNames - Object|[String].
The state names which will replace
DataRowState constant values.
It can be JSON object which contains DataRowState
or an array which contains names in "created", "updated", "deleted", "createAndDeleted" order.
If do not set "createAndDeleted", it will be specified as "deleted" value.
- emptyValue - *.
The value which replaces
undefined field values.
(When
undefined field is object property,
it will not be contained in
JSON.stringify.)
Code -1
// Get all rows of which state is not NONE.
var rows = ds.getModifiedRowObjects();
// or
var rows = ds.getModifiedRowObjects(null);
Code -2
// Get the rows of which state is created.
var rows = ds.getModifiedRowObjects(DataLudi.DataRowState.CREATED);
Code -3
// Get the rows of which state is created, deleted.
var rows = ds.getModifiedRowObjects([DataLudi.DataRowState.CREATED, DataLudi.DataRowState.DELETED]);
Code -4
// You can change or add the value of returned rows if necessary.
var rows = ds.getModifiedRowObjects(null, function (ds, row, rowObject) {
// Change the existing value
rowObject["Addr"] += '_X';
// or add new property.
rowObject["row_id"] = row + 1;
});
Code -5
// You can specify the state property name as other name rather than "row_state", and can also specify the state values differently.
var rows = ds.getModifiedRowObjects(null, null, '_state', ['c', 'u', 'd']);
Code -6
// Specify the property value of undefined as other value. The property value of undefined will be removed from JSON.stringify().
var rows = ds.getModifiedRowObjects(null, null, null, null, '');
- See Also
- DataRowState
- getRowState
- getRowObject
- getRowObjects
- getRow
- getRows
- JSON.stringify
- Examples
- Data Row States
- Grid Data Set Rows