Insert values into grid
You can directly change or add cells, rows, or multiple rows at the same time to the DataProvider to respond to screen configuration or special needs.
The index used by dataProvider is dataRow, and the index used by GridView is itemIndex. There is no difference between these two indexes when initially loading data, but differences occur during sorting, filtering, and grouping. dataRow does not change if there are no row insertions or deletions since the data was first loaded. (When sorting, there may be differences from the order shown on the screen) itemIndex is the order visible to the user.
If you're editing row data, see the demo below. Edit row data
For events that occur during editing, check Event occurrence order.
Functions for entering grid values
This is a function to input the value of dataProvider
.
This is a function to enter the value of gridView
.
Putting values into grid
You can change the value of a data cell (one field in a row). The grid below is sorted by name. Press setValue of dataProvider and gridView to see the difference.
The grid below is sorted by name.
dataProvider.setValue()
var current = gridView.getCurrent();
var dataRow = current.dataRow;
var fieldName = current.fieldName;
var value = "Cell (" + fieldName + ", " + dataRow + ")";
dataProvider.setValue(dataRow, fieldName, value);
gridView.setValue()
var current = gridView.getCurrent();
var itemIndex = current.itemIndex;
var fieldName = current.fieldName;
var value = "Cell (" + fieldName + ", " + itemIndex + ")";
gridView.setValue(itemIndex, fieldName, value);
caution
If the grid is being edited at the time of calling the DataProvider's data function, an error "Clinet is editing"
will occur.
User editing and DataProvider function calls cannot proceed simultaneously.
You must first complete user editing by calling gridView.commit() and gridView.cancel() before calling the dataProvider. You need to call a function.