Hello,
As far as I understand, the row values you want to calculate then should be saved to GridView's data source. If so, please note that the Inline editing mode does not allow you to modify multiple rows simultaneously. You can edit values of only one row.
As a possible solution, I recommend you consider using the Batch Edit mode instead.
Also, I suggest you refer to the ASPxClientGridView.batchEditApi help topic. This topic contains method definitions, which should help you change cells values. You can use the ASPxClientGridView.batchEditApi.SetCellValue method to set a value to a cell.
Thanks,
Stanley
-
Stanley,
thanks for putting me back on the right track.
Of course now I have a bunch of new questions about gridview in batch edit mode (get rid of focused cell border,...),
but this is a question for another ticket.Thanks again.
Stanley,
would you be so kind and show me how to find row index based on value of VP (VP is not a key field).
[JavaScript]function SpinEdit_OnNumberChanged(s, e, index) { var cellInfo = gridViewTest2.batchEditApi.GetEditCellInfo(); var colVal = s.GetValue(); if (colVal === null) colVal = 0; else colVal = -1 * colVal; // just a test var rowIndex = 3; // get index of row with VP = 827 gridViewTest2.batchEditApi.SetCellValue(rowIndex , cellInfo.column.index, colVal, null, false); }
rowIndex is not a current editing row, but is always a row with VP = 827 (for example)
Hello,
As far as I see in your code, you are implementing a Data Item template. Would you please send me your ASPxGridView markup and code behind for further research? Also, clarify whether the "VP" is used as a key field. This will help me provide you with further recommendations.
Thanks,
StanleyHello,
Here is a snippet
VP is not a key![C#]settings.Columns.Add(columnSettings => { columnSettings.Caption = "Zg. Meja"; columnSettings.FieldName = "ZgornjaMeja"; columnSettings.Width = 80; columnSettings.ColumnType = MVCxGridViewColumnType.SpinEdit; columnSettings.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; columnSettings.CellStyle.HorizontalAlign = HorizontalAlign.Center; columnSettings.EditorProperties().SpinEdit(p => { p.NumberType = SpinEditNumberType.Integer; p.FocusedStyle.BackColor = System.Drawing.Color.Yellow; p.Style.HorizontalAlign = HorizontalAlign.Center; p.SpinButtons.Visible = false; p.SpinButtons.ClientVisible = false; p.ValueChangedDelay = 0; p.ClientSideEvents.NumberChanged = "SpinEdit_OnNumberChanged"; p.ShowOutOfRangeWarning = true; //p.ValidationSettings.ErrorTextPosition = ErrorTextPosition.Bottom; p.ValidationSettings.Display = Display.Dynamic; p.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.Text; p.ValidationSettings.SetFocusOnError = true; p.ValidationSettings.ValidateOnLeave = true; }); });
Hope this helps!
Thanks
Thank you for the clarification. You can find the whole list of batch editing client API methods here: ASPxClientGridViewBatchEditApi Members. So, you can use the GetCellValue or GetCellValueByKey method to get a cell's value. If you know the key field value, then use the second method. Otherwise, you will have to loop through rows to find the necessary cell's visible index. For example:
[JavaScript]var rowCount = grid.GetVisibleRowsOnPage(); for (var i = 0; i < rowCount; i++) { var myValue = grid.batchEditApi.GetCellValue(i, "VP"); //your code }
Thanks,
StanleyThank you Stanley for your time.
I figure this out about an hour ago, and then I hit the wall again.
This would only work if I don't use paging ( SettingsPager.Mode is set to ShowAllRecords).Otherwise it will only loop through the current page.
Last hour was spent trying to find the solution to loop through all rows?Could you also provide the solution for this?
Thanks
Hello,
1. Use the "ShowAllRecords" mode as you mentioned earlier. If you do not have too many records in your data source, you should not face performance issues.
Thank you for the clarification. You are right, it is not possible to set values of hidden rows. I suggest you consider using one of the following approaches:
2. Adjust the SettingsPager.PageSize property so that the required rows are rendered in the browser.
3. Handle the client-side BeginCallback event handler, catch the callback request for batch updating, calculate the necessary values, and add them to the EventArgs customArgs collection. For example:
[JavaScript]function onBeginCallback(s, e) { if (e.command == ASPxClientGridViewCallbackCommand.UpdateEdit) { //calculations e.CustomArgs["yourValue"] = yourValue; } }
4. Get the required data from GridView's data source and then manually implement all CRUD commands on the server side in the corresponding action method for batch editing.[C#][ValidateInput(false)] public ActionResult BatchEditingUpdateModel(MVCxGridViewBatchUpdateValues<EditableProduct, int> updateValues, string yourValue) { ... }
Thanks,
Stanley