In a RadGrid, in the OnBatchEditOpening Javascript event, how to get the value of the cell?

1 Answer 24 Views
Grid
Nancy
Top achievements
Rank 1
Iron
Nancy asked on 22 Feb 2024, 12:02 AM

Hi,

I would like to use a version of this code

// Event fires upon a cell is intering into edit mode
function OnBatchEditOpening(sender, args) {

    // get the unique name of the column
    var columnName = args.get_columnUniqueName();

    // get the currently edited row's ID
    var rowId = parseInt(args.get_row().id.split("__")[1]);

    // Setup a condition for the row ID
    if (rowId % 3 == 0) { // If condition 1 is met

        // if this row and the Freight column
        if (columnName == "Freight") {
            // cancel the Editing event
            args.set_cancel(true);
        }
    } 
}

to get the value of the cell.  If the cell is empty (null or a space), then I don't want the cell to be editable.  In this Javascript, how do I get the actual value of the cell?

This code is getting me close

var cell = args.get_cell();
alert(cell.childNodes[0].innerHTML)

but it is showing the whole span, like this:
<span id="ctl00_MainContent_mygrid_ctl00_ctl10_mylabel">this is the value I want to access</span>

Thanks!

1 Answer, 1 is accepted

Sort by
0
Nancy
Top achievements
Rank 1
Iron
answered on 22 Feb 2024, 12:16 AM

Never mind, I figured it out.  It needs to be .innerText.  This works:

        function OnBatchEditOpening(sender, args)
        {
            var cell = args.get_cell();
            if (cell.childNodes[0].innerText == "")
                args.set_cancel(true);
        }

Thanks!

 

Tags
Grid
Asked by
Nancy
Top achievements
Rank 1
Iron
Answers by
Nancy
Top achievements
Rank 1
Iron
Share this question
or