How to iterate a RadGrid using javascript to find whether checkboxes are checked for each row

6 posts, 0 answers
  1. jnh999
    jnh999 avatar
    29 posts
    Member since:
    Apr 2010

    Posted 27 Mar 2013 Link to this post

    Hi, Telerik,
    I have a RadGrid with a checkbox in each row.  I need to use JavaScript to iterate each row and check and see whether each row are checked. The checkbox is defined in <telerik:GridTemplateColumn> in MasterTableView.  How do I do that? 
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Mar 2013 Link to this post

    Hi,

    Try the following javascript.
    JS:
    function onclick() {
       var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
       var row = masterTable.get_dataItems();
       for (var i = 0; i < row.length; i++)
       {
           var chk=masterTable.get_dataItems()[i].findElement("CheckBox1");
       }
    }

    Thanks,
    Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. jnh999
    jnh999 avatar
    29 posts
    Member since:
    Apr 2010

    Posted 28 Mar 2013 Link to this post

    Thank you.  It worked.
    Another follow up question.  I need to get other values in the same row.  How do I get that.  the rendered html is as follows:

    <td>
    <span title="CV-2">
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 01 Apr 2013 Link to this post

    Hi,

    Try the following javascript.
    JS:
    function onclick() {
       var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
       var row = masterTable.get_dataItems();
       for (var i = 0; i < row.length; i++)
       {
           var input=masterTable.get_dataItems()[i].findElement("input1");
       }
    }

    Thanks,
    Shinu
  6. kunigiri
    kunigiri avatar
    1 posts
    Member since:
    Sep 2015

    Posted 16 Dec 2015 in reply to Shinu Link to this post

    Hi 

     i am using this code but i am not getting the Mastertable view data. it is showing error.undefined.my requirement is i am having telerik gird with check box and bound column , on submit click for that page i need to check whether the check box is clicked or not , if no check box does not checked then need alert message. please help me in this as soon possible.

    Thanks 

    indraja

  7. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 21 Dec 2015 Link to this post

    Hi Кunigiri,

    You can traverse the grid items and once you have a reference to the the grid item within the for loop, you can use findElement or findControl methods to get the checkBox or simply use the get_selected() method:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/hierarchical-grid-types-and-load-modes/traversing-detail-tables#looping-through-the-detail-tablesitems-in-telerik-radgrid-on-the-client

    I am also sending a sample RadGrid web site to demonstrate a practical implementation with findControl() and findElement() methods. Please examine the attached application and let me know if it helps you.

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017