This is a migrated thread and some comments may be shown as answers.

Grid batch edit; update neighbor cell value without disrupting the grid's data flow.

3 Answers 269 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Austin
Top achievements
Rank 1
Austin asked on 04 Jun 2018, 06:52 PM

I have a RadGrid in batch edit mode, cell edit.  I'm using the events 'OnBatchEditOpened' to manipulate some of the UI before the user gets to see/use it and then 'BatchEditCellValueChanged' to run further logic.

 

I have a pair of cells in the grid, in column X, that need to be the opposite of each other's selections in the rad comboBox I'm using in the editor.  If one cell has optionA selected in row A then the other cell needs to show optionB in row B.  The issue I'm running into is that to change cell values I have been using this method:

    batchManager.changeCellValue(cellToChange, valueToUse).

This works fine...normally when I'm updating values in some OTHER grid.  But when I run this logic from the 'BatchEditCellValueChanged' method of the SAME GRID then the grid gets a bit wonky.  I already have code to avoid recursive looping.  The problem is that the grid has a set of functions that are fired in a set sequence, like opening, opened, changing, changed, closing, closed, etc.  When you cause that data flow to step INTO itself before the first is finished... it winds up leaving the edit control visible in the starting cell.

So - CellA opens in editor, I select the radComboBox option A and tab out of the cell.  This causes Telerik's event chain to start firing... it gets to 'BatchEditCellValueChanged' and runs my code.  My code then tell the SAME grid to update CellB in the other row... and that starts the grid's event chain to START OVER... before CellA's 'value changed' event is finished.  I think this is what is causing the logic issues and is making the editor, i.e. the radComboBox in CellA, to remain visible even after I exit the cell.

 

So - all that being said.  What is the 'correct' way to change cellB's in row B when cellA's value changes in rowA of the same batch edit grid?

 

3 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 07 Jun 2018, 08:58 AM
Hi Austin,

Perhaps a timeout will allow the built-in code to finish its work so only after that will the custom logic go and change all other cells. Something like:

function BatchEditCellValueChanged(sender, args) {
    //code
    setTimeout(function () {
        //batchManager.changeCellValue(cellToChange, valueToUse)
    });//you can also try playing with the timeout, for example 100 ms would hardly be noticeable for the end user but if the default value is not engough, it may help (it may not be enough if there is some other timeout in the built-in grid code)
}


Regards,
Marin Bratanov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Austin
Top achievements
Rank 1
answered on 07 Jun 2018, 12:58 PM

Honestly I had considered doing just that, but wanted to make sure there wasn't some officially supported method I was missing.  We try to stick with directly supported solutions as much as possible and avoid digging into "hacky" territory since the concern is when things change across release levels that something may break.

I have had to dump a lot of hours getting some stuff ready for IE11 support and already implemented an approach that simply uses validation to require the change be made manually by the user.  I will try to upgrade to automating the task for them with this approach when I get a chance.  I will TRY to remember to post back how it goes. 

Thanks for the feedback.

0
Marin Bratanov
Telerik team
answered on 07 Jun 2018, 02:35 PM
Hello Austin,

I do hope things turn our well and it doesn't take much time. Best of luck with the project moving onward!


Regards,
Marin Bratanov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Austin
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Austin
Top achievements
Rank 1
Share this question
or