Current filter:
                                You should refresh the page.
                                  • Hello!

                                    I have a gridview with some rows added by user (selected from the list and added to the gridview).
                                    Each row has its special meaning and is defined by number VP.
                                    Some rows are "locked" because user should not enter this value (in this example only 1 row is locked).
                                    Values for locked rows should be automatically calculated when user changes values in current editing row/cell.
                                    Equation for each calculation can be different.
                                    Each cell is represented by Spin Edit control with hidden buttons.

                                    Example from the image.
                                    Row with VP=827 always depends on value in row with VP=101. Any changes in row 101 should automatically reflect changes in row 827.
                                    For this example 827 cell is calculated like this:
                                       if 101 cell is empty -> 827 is empty
                                       if   0 <  101   <= 8 is -> 827 = 1
                                       otherwise 827 = 0

                                    This change should reflect immediately when value of cell in row 101 changes, however calculated values should only be posted when row 101 is Updated.

                                    I am using GridView Toolbars for CRUD operations.

                                    There are few more relations between these rows, but the idea is the same.
                                    Master row's cell is edited and its pre-defined dependant row's cell is calculated.

                                    Is this possible?

                                    I hope you will understand what I mean.

                                    Thanks.

                                1 Solution

                                Creation Date Importance Sort by

                                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

                                Show all comments
                                • DamjanSTEEL 08.20.2019

                                  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.

                                • DamjanSTEEL 08.22.2019

                                  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)

                                • Stanley (DevExpress Support) 08.22.2019

                                  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,
                                  Stanley

                                • DamjanSTEEL 08.22.2019

                                  Hello,

                                  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

                                • Stanley (DevExpress Support) 08.22.2019

                                  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,
                                  Stanley

                                • DamjanSTEEL 08.22.2019

                                  Thank 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

                                • Stanley (DevExpress Support) 08.23.2019

                                  Hello,
                                  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:

                                  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.
                                  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; } }
                                  [C#]
                                  [ValidateInput(false)] public ActionResult BatchEditingUpdateModel(MVCxGridViewBatchUpdateValues<EditableProduct, int> updateValues, string 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.

                                  Thanks,
                                  Stanley