get reference to radgrid inside another radgrid

10 posts, 0 answers
  1. cognos s
    cognos s avatar
    35 posts
    Member since:
    Oct 2009

    Posted 09 Nov 2009 Link to this post

    Here is what I have:
    I have a radgrid and in one of its column I show another radgrid. Parent(StudentsGrid) and Child(AttendanceGrid). For each student record there can be more than one attendance. I provide a checkbox in attendancegrid so the user can delete a particular attendance. I would like to get the selected attendance records. below is the code that I have until now. I would like to do this on client side not on server side.

    pls let me know how to solve this.

     

     

     

     

    function rowSelected() {

     

     

     

          var grid = $find("<%= rgStudents.ClientID %>");

     

     

          var masterTable = grid.get_masterTableView();

     

     

          var rows = masterTable.get_dataItems();

     

     

          for (var i = 0; i < rows.length; i++) {
                 var
    cell = masterTable.getCellByColumnUniqueName(rows[i], "Attendance");

     

                  // how to get the reference to attendance radgrid and loop through its checked items????
    }

     

     

     

     

     


    <telerik:RadGrid ID="rgStudents" runat="server" AutoGenerateColumns="false">                     
                <MasterTableView DataKeyNames="StudentId">
                    <Columns>     
                       
                        <telerik:GridBoundColumn DataField="StudentId" UniqueName="StudentId" Visible="false" />
                        <telerik:GridBoundColumn DataField="FName" UniqueName="FName" HeaderText="First Name" />
                        <telerik:GridBoundColumn DataField="LName" UniqueName="LName" HeaderText="Last Name" />                   
                         <telerik:GridTemplateColumn HeaderText="Attendance" UniqueName="Attendance">
                            <ItemTemplate>
                                <telerik:RadGrid ID="rgAttendance" runat="server" AutoGenerateColumns="false" AllowMultiRowSelection="true" >
                                   <ClientSettings>
                                            <Selecting AllowRowSelect="true" />
                                             <ClientEvents OnRowSelected="rowSelected" OnRowDeselected="rowDeselected" />                               
                                   </ClientSettings>
                                   <MasterTableView DataKeyNames="AttendanceID">
                                       
                                        <Columns>
                                            <telerik:GridBoundColumn DataField="AttendanceId" UniqueName="AttendanceId" Visible="false" />                                       
                                            <telerik:GridBoundColumn DataField="CourseNo" HeaderText="CourseNo" />
                                            <telerik:GridBoundColumn DataField="Attendance" HeaderText="Date" />                                       
                                            <telerik:GridClientSelectColumn UniqueName="checkboxDelete"/>
                                        </Columns>
                                   </MasterTableView>                               
                                </telerik:RadGrid>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>             
                    </Columns>       
                </MasterTableView>
            </telerik:RadGrid>

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 10 Nov 2009 Link to this post

    Hello Cognos,

    Try out the following code to access selected items in the nested RadGrid:
    js:
    function rowSelected(sender,eventArgs) 
         { 
              var grid = $find("<%= RadGrid1.ClientID %>"); 
              var masterTable = grid.get_masterTableView(); 
              var rows = masterTable.get_dataItems(); 
              for (var i = 0; i < rows.length; i++)  
              { 
                 var cell = masterTable.getCellByColumnUniqueName(rows[i], "Attendance"); 
              } 
               var selectedRows = sender.get_masterTableView().get_selectedItems();// where sender is the rgAttendance grid 
     
         } 
         

    Hope this helps..
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. cognos s
    cognos s avatar
    35 posts
    Member since:
    Oct 2009

    Posted 10 Nov 2009 Link to this post

    i get "object does'nt support this property or method" error with this line:
    var selectedRows = sender.get_masterTableView().get_selectedItems();
  5. cognos s
    cognos s avatar
    35 posts
    Member since:
    Oct 2009

    Posted 10 Nov 2009 Link to this post

    can anybody pls give me a reply...its urgent.
  6. cognos s
    cognos s avatar
    35 posts
    Member since:
    Oct 2009

    Posted 16 Nov 2009 Link to this post

    any reply?
  7. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 18 Nov 2009 Link to this post

    Hi Cognos,

    Please examine the following links:
    Referencing controls in grid row/edit form
    Acessing cells and rows

    Best wishes,
    Pavlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. cognos s
    cognos s avatar
    35 posts
    Member since:
    Oct 2009

    Posted 18 Nov 2009 Link to this post

    I would like to do this in javascript not server side. I have come through some point as per the code posted above and got stuck there. can you pls modify my javascript and get it working. I am new to using telerik controls.
  9. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 23 Nov 2009 Link to this post

    Hello cognos,

    Go through the following help article which explains how to access selected row's cell value on the client side.
    Getting cell values for selected rows client side

    Sincerely yours,
    Pavlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  10. Mark Galbreath
    Mark Galbreath avatar
    171 posts
    Member since:
    Jul 2009

    Posted 24 Nov 2009 Link to this post

    Can you pls modify my javascript and get it working? 

    And when you are done, will you write my code for me, too?  ;-)

    Seriously, is anybody at Telerik rewriting the client-side API documentation?  It is sooooo horrible!

    Cheers!
    Mark
  11. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 27 Nov 2009 Link to this post

    Hello Mark,

    Attached to this message is a simple working project which handles the desired functionality. Please give it a try and let me know how it goes.

    I hope this helps.

    Kind regards,
    Pavlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017