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

Example code for ClientEvents OnBatchEditCellValueChanged

8 Answers 208 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 11 Jul 2013, 07:49 PM

Could you please provide sample code for the new batch editing functionality for OnBatchEditCellValueChanged. I need to know the following:
1. The index of the row (to get values of other columns)
2. The ID of the column
3. Old value
4. New value

Thank you,
-Sam

8 Answers, 1 is accepted

Sort by
0
Sam
Top achievements
Rank 1
answered on 15 Jul 2013, 03:34 PM
Any help would be appreciated.

Thanks,
-Sam
0
Angel Petrov
Telerik team
answered on 16 Jul 2013, 02:24 PM
Hi Sam,

You can directly extract the old and new values from the arguments. However in order to extract the rest of the data you will need to obtain a reference to the batch editing manager. A demonstration on how to extract the values is shown in the code snippet below.

JavaScript:
function onBatchEditCellValueChanged(sender,args) {
            var data = sender.get_batchEditingManager()._getCellDataToOpenEdit(sender.get_batchEditingManager().get_currentlyEditedCell());
            var row = data.row;
            var rowIndex = row.rowIndex;
            var columnName = data.columnUniqueName;
            var cell = data.cell;
            var oldValue = args.get_cellValue();
            var newValue = args.get_editorValue();
        }


Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Jim
Top achievements
Rank 1
answered on 19 Jul 2013, 07:36 PM

Can you provide a working demo of this using TemplateColumns?
This is always returning null.
0
Angel Petrov
Telerik team
answered on 24 Jul 2013, 02:25 PM
Hello Jim,

This is not an expected behavior. Could you please show us the template column declaration? When more than one control which contains an input element are placed inside the EditItemTemplate things should be handled manually like demonstrated in this help article. That said it would be best to elaborate more on your scenario so we could provide a proper solution.

Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Jim
Top achievements
Rank 1
answered on 25 Jul 2013, 12:52 PM

I seem to be able to find it this way:

sender._batchEditing._currentlyEditedCellInfo.columnUniqueName()


however, ONLY IF

EditType="Cell"

I am trying to use EditType="Row" on a DetailTable.
0
Antonio Stoilkov
Telerik team
answered on 30 Jul 2013, 11:15 AM
Hi Jim,

We have made couple of improvements in the batch editing functionality which will be available in the next week internal build. One of the improvements is additional arguments in the GridBatchCellValueChanging and GridBatchCellValueChanged which will let you access all relevant information including the cell and the column unique name. You could take a look at the example below which you could use with the internal build that will be uploaded next week.
function CellValueChanged(sender, args)
{
    var row = args.get_row();
    var rowIndex = row.rowIndex;
    var columnName = args.get_columnUniqueName();
    var cell = args.get_cell();
    var oldValue = args.get_cellValue();
    var newValue = args.get_editorValue();
}

Regards,
Antonio Stoilkov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Allen
Top achievements
Rank 1
answered on 23 Sep 2013, 05:44 PM
I try your codes, but I receive error "Microsoft JScript runtime error: Unable to get value of the property 'columnUniqueName': object is null or undefined".  Please refer to the png file.  My codes is as follows:
function OnBatchEditCellValueChanging(sender, eventArgs) {
                var data = sender.get_batchEditingManager()._getCellDataToOpenEdit(sender.get_batchEditingManager().get_currentlyEditedCell());
                var columnName = data.columnUniqueName;
                var cell = data.cell;
                var oldValue = eventArgs.get_cellValue();
                var newValue = eventArgs.get_editorValue();
                var fromWeek_CellValue = data.cell.innerText
                if (columnName == 'TO_WEEK') {
                    if (newValue <= fromWeek_CellValue) {
                        alert("To_Week can not be lees than or equal to From_Week")
                        eventArgs.set_cancel(true);
                    }
                }
                if (columnName == 'FROM_WEEK') {
                    var toWeek_CellValue = data.cell.innerText;
                    if (newValue >= toWeek_CellValue) {
                        alert("From_Week can not be lees than or equal to To_Week")
                        eventArgs.set_cancel(true);
                    }
                }
            }
0
Antonio Stoilkov
Telerik team
answered on 26 Sep 2013, 07:54 AM
Hi Allen,

As shown in the previous post you could use the event arguments which are passed as second parameter in the OnBatchEditCellValueChanging event to access the cell and the associated columnUniqueName. Note that this functionality is included in our Beta release that will be released this week.
function CellValueChanged(sender, args)
{
    var row = args.get_row();
    var rowIndex = row.rowIndex;
    var columnName = args.get_columnUniqueName();
    var cell = args.get_cell();
    var oldValue = args.get_cellValue();
    var newValue = args.get_editorValue();
}

The new approach have been implemented in order to avoid using private methods(functions starting with underscore).

Regards,
Antonio Stoilkov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Sam
Top achievements
Rank 1
Answers by
Sam
Top achievements
Rank 1
Angel Petrov
Telerik team
Jim
Top achievements
Rank 1
Antonio Stoilkov
Telerik team
Allen
Top achievements
Rank 1
Share this question
or