RadGrid Batch Edit Checkbox Column Client Event

2 posts, 0 answers
  1. Lannity
    Lannity avatar
    5 posts
    Member since:
    Jul 2012

    Posted 07 May 2015 Link to this post


    I want to call a Javascript function on a batch edit enabled grid for the actual moment the user clicks the checkbox, checking or unchecking the value on a GridCheckBoxColumn checkbox control in the grid.  The JavaScript function called should be able to reference the row to which the clicked checkbox belongs in order to change any values in the same row.

    Where in the batch edit grid do I setup the call to the function for the GridCheckBoxColumn click event in a way that allows setting up the (sender, args) parameters that allow manipulating data in the row which contains the clicked checkbox?

    Many thanks for your help in advance.


  2. Konstantin Dikov
    Konstantin Dikov avatar
    2466 posts

    Posted 12 May 2015 Link to this post

    Hi Lannity,

    I am posting the answer from the support ticket that you have opened with the same question:

    "The easiest way for getting reference to the row and the data item when the value of the check box is changes is by handling the client-side OnBatchEditCellValueChanged event of the grid. For your convenience, following is a simple example demonstrating such implementation:
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function pageLoad() {
            function valueChanged(sender, args) {
                if (args.get_columnUniqueName() == "rgcExcellent") {
                    var row = args.get_row();
                    var dataItem = $find(row.id);
                    var idCell = dataItem.get_cell("ID");
                    var batchManager = sender.get_batchEditingManager();
                    batchManager.changeCellValue(idCell, 9);
                    //call the line below if you are going to change values in other cells
    <telerik:RadGrid runat="server" ID="RadGrid1"OnNeedDataSource="RadGrid1_NeedDataSource">
        <MasterTableView AutoGenerateColumns="false" EditMode="Batch">
                <telerik:GridBoundColumn DataField="ID"></telerik:GridBoundColumn>
                <telerik:GridCheckBoxColumn UniqueName="rgcExcellent"DataField="ExcellenceMarker"></telerik:GridCheckBoxColumn>
            <ClientEvents OnBatchEditCellValueChanged="valueChanged" />

    And some dummy data:
    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        DataTable table = new DataTable();
        for (int i = 0; i < 5; i++)
            table.Rows.Add(i, i % 2 == 0);
        (sender as RadGrid).DataSource = table;

    As you can notice, I have also demonstrated how to use the data item for getting reference to a particular cell and how to change the value of that cell."

    Konstantin Dikov

    See What's Next in App Development. Register for TelerikNEXT.

Back to Top