ASPxClientGridView.GetRowValues(visibleIndex, fieldNames, onCallback) Method
Returns the values of the specified data source fields within the specified row.
Declaration
GetRowValues(
visibleIndex: number,
fieldNames: string,
onCallback: ASPxClientGridViewValuesCallback
): void
Parameters
Name | Type | Description |
---|---|---|
visibleIndex | number | An integer value that identifies the data row’s index. |
fieldNames | string | The names of data source fields separated by a semicolon, whose values within the specified row are returned. |
onCallback | ASPxClientGridViewValuesCallback | An ASPxClientGridViewValuesCallback object that represents the JavaScript function which receives the list of row values as a parameter. |
Remarks
Note
If you pass a single field as a fieldNames parameter to the GetRowValues method, the ASPxClientGridView.GetRowValues method’s onCallback parameter receives a single value as a parameter, rather than a list of row values.
In this case, your function should work with a single value instead of the list of values. A working example is shown in the code sample below:
// function is called on changing focused row
function OnGridFocusedRowChanged() {
// Query the server for the "EmployeeID" field from the focused row
// The single value will be returned to the OnGetRowValues() function
grid.GetRowValues(grid.GetFocusedRowIndex(), 'EmployeeID', OnGetRowValues);
}
// Value contains the "EmployeeID" field value returned from the server, not the list of values
function OnGetRowValues(value) {
// Right code
alert(value);
// This code will cause an error
// alert(value[0]);
}
Example
This example illustrates how to dynamically display a focused employee’s photo and details outside the grid.
In the example, handle the ASPxClientGridView.FocusedRowChanged event to call the OnGridFocusedRowChanged() function. This function queries the server to return the employee’s ID and Notes. Pass the returned array to the OnGetRowValues() function that specifies values for corresponding HTML elements.
WebForms approach:
Note
For a full example, see Grid Rows - Focused Row demo.
function OnGridFocusedRowChanged() {
grid.GetRowValues(grid.GetFocusedRowIndex(), 'EmployeeID;Notes', OnGetRowValues);
}
function OnGetRowValues(values) {
var notes = document.getElementById("detailnotes");
notes.value = values[1];
var image = document.getElementById("detailimage");
image.src = "FocusedRow.aspx?Photo=" + values[0];
}
MVC approach:
Note
For a full example, see Grid Rows - Focused Row demo.
function OnGridFocusedRowChanged(s, e) {
s.GetRowValues(s.GetFocusedRowIndex(), 'EmployeeID;Notes', OnGetRowValues);
}
function OnGetRowValues(values) {
DetailPhoto.SetImageUrl("@GridViewRowsDemosHelper.GetEmployeeImageRouteUrl()?@GridViewRowsDemosHelper.ImageQueryKey=" + values[0]);
DetailNotes.SetText(values[1]);
}
The image below shows the result: