Sometimes the foreground completes an operation to modify the value of the DataGrid, perhaps the DataGrid is not saved, so to be modified to pass to the background; may need to request the background after other operations; These situations require the foreground to modify the DataGrid's cells:
Suppose we have a "stafflogdetailgrid" of the DataGrid;
Get the Columns object var columns = $ (' #dg '). DataGrid ("Options"). columns;//get the Rows object var rows = $ (' #dg '). DataGrid ("GetRows"); This code is//to a cell assignment value rows[lastindex][columns[0][5].field]= new value,//Refresh the row, only refresh the effect of $ (' #dg '). DataGrid (' Refreshrow ', LastIndex);
If the row is in the row edit state, call the "Refreshrow" method directly. Will report data is undefined this error; Need to call "EndEdit", then call "Refreshrow", and finally call "SelectRow" and "BeginEdit" two methods can be; Be sure to close the line edit before you can refresh, or to error ... This problem has made me a long time ... The code is as follows:
$ (' #dg '). DataGrid (' EndEdit ', LastIndex). DataGrid (' Refreshrow ', LastIndex). DataGrid (' SelectRow ', LastIndex). DataGrid (' BeginEdit ', lastIndex);
There is also a way to edit cells: the following
The known line coordinates are lastindex;
var row = $ (' #dg '). DataGrid ("SelectRow", LastIndex). DataGrid ("getselected"); ROW.GZSJ = Getnowdate (); Console.info (row ); $ (' #dg '). DataGrid (' UpdateRow ', row);
Easyui The foreground changes the value of a cell in the DataGrid