Get the value of the grid
You can get the values of data cells and rows through several functions of GridView and DataProvider.
If the grid is not being edited, it returns the same value by default.
Unless there are special cases, the value is retrieved from dataProvider and used.
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.
Get value from dataProvider
You can get the value
value corresponding to the dataRow
and field
values of the current focus position.
Check how date data is returned in getJsonRow() and getOutputRow().
- getValue(dataRow, field)
- getValues(dataRow)
- getJsonRow(dataRow)
- getOutputRow(options, dataRow)
- getRows(startRow, endRow)
- getJsonRows(startRow, endRow)
- getOutputRows(options, startRow, endRow)
- getFieldValues(field, startRow, endRow)
The grid below is sorted by name.
getValue
var current = gridView.getCurrent();
var value = dataProvider.getValue(current.dataRow, current.fieldName);
alert("dataRow: " + current.dataRow + ", " + "field: " + current.fieldName + ", " + "value: " + value);
getValues
It can be imported as an Array
containing field values of one row in order.
var current = gridView.getCurrent();
alert("dataRow: " + current.dataRow + ", " + dataProvider.getValues(current.dataRow));
getJsonRow
You can retrieve the value of one row as a Json object
.
var current = gridView.getCurrent();
var jsonData = dataProvider.getJsonRow(current.dataRow);
alert("dataRow: " + current.dataRow + ", " + JSON.stringify(JsonData));
getOutputRow
You can get one row of values matching the set options as Object
.
options
sets the method of returning data.
var options = { datetimeFormat: "yyyy-MM-dd" };
var current = gridView.getCurrent();
var outputRowData = dataProvider.getOutputRow(options, current.dataRow);
alert("dataRow: " + current.dataRow + ", " + JSON.stringify(outputRowData))
getRows
You can import data from multiple rows as an Array of Array
.
startRow
defaults to 0, and if it is less than 0, the first row is fetched.
endRow
defaults to -1, with -1 fetches up to the last row.
alert(dataProvider.getRows(0, -1));
getJsonRows
You can import data from multiple rows as an Array of Json objects
.
startRow
defaults to 0, and if it is less than 0, the first row is fetched.
endRow
defaults to -1, with -1 fetches up to the last row.
alert(JSON.stringify(dataProvider.getJsonRows(0, -1)));
getOutputRows
You can import multiple rows of data matching the set options as Object
.
options
sets the method of returning data.
startRow
defaults to 0, and if it is less than 0, the first row is fetched.
endRow
defaults to -1, with -1 fetches up to the last row.
var options = { datetimeFormat: "yyyy-MM-dd" };
alert(JSON.stringify(dataProvider.getOutputRows(options, 0, -1)))
getFieldValues
The values of one field at the current focus position can be imported into an Array
up to the specified row range.
var current = gridView.getCurrent();
alert("field: " + current.fieldName + ", " + "fieldValues: " + dataProvider.getFieldValues(current.fieldName, 0, -1));
Get value from GridView
You can get the value
value corresponding to the itemIndex
and field
value of the current focus position.
Check how date and numeric data are returned in getValues(), getDisplayValues(), and getDisplayValuesOfRow().
- getValue(itemIndex, field)
- getValues(itemIndex)
- getJsonRows()
- getDisplayValues(itemIndex,useColumnName)
- getDisplayValuesOfRow(dataRow,useColumnName)
The grid below is sorted by name.
getValue
var current = gridView.getCurrent();
var value = gridView.getValue(current.itemIndex, current.fieldName);
alert(
"itemIndex: " +
current.itemIndex +
", " +
"field: " +
current.fieldName +
", " +
"value: " +
value
);
getValues
var current = gridView.getCurrent();
alert(
"itemIndex: " + current.itemIndex + ", " + JSON.stringify(gridView.getValues(current.itemIndex))
);
getJsonRows
alert(JSON.stringify(gridView.getJsonRows()));
getDisplayValues
The value displayed on the screen, not the actual value, is retrieved as is using itemIndex.
var current = gridView.getCurrent();
var jsonData = gridView.getDisplayValues(current.itemIndex);
alert("itemIndex: " + current.itemIndex + ", " + JSON.stringify(jsonData));
getDisplayValuesOfRow
The value displayed on the screen, not the actual value, is retrieved as is using dataRow.
var current = gridView.getCurrent();
var jsonData = gridView.getDisplayValuesOfRow(current.dataRow);
alert("dataRow: " + current.dataRow + ", " + JSON.stringify(jsonData));