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

get reference to radgrid inside another radgrid

9 Answers 168 Views
Grid
This is a migrated thread and some comments may be shown as answers.
cognos s
Top achievements
Rank 1
cognos s asked on 09 Nov 2009, 05:50 PM

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>

9 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Nov 2009, 07:11 AM
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.
0
cognos s
Top achievements
Rank 1
answered on 10 Nov 2009, 01:20 PM
i get "object does'nt support this property or method" error with this line:
var selectedRows = sender.get_masterTableView().get_selectedItems();
0
cognos s
Top achievements
Rank 1
answered on 10 Nov 2009, 11:30 PM
can anybody pls give me a reply...its urgent.
0
cognos s
Top achievements
Rank 1
answered on 16 Nov 2009, 07:12 PM
any reply?
0
Pavlina
Telerik team
answered on 18 Nov 2009, 04:00 PM
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.
0
cognos s
Top achievements
Rank 1
answered on 18 Nov 2009, 09:09 PM
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.
0
Pavlina
Telerik team
answered on 23 Nov 2009, 04:31 PM
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.
0
Mark Galbreath
Top achievements
Rank 2
answered on 24 Nov 2009, 02:44 PM
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
0
Pavlina
Telerik team
answered on 27 Nov 2009, 02:45 PM
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.
Tags
Grid
Asked by
cognos s
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
cognos s
Top achievements
Rank 1
Pavlina
Telerik team
Mark Galbreath
Top achievements
Rank 2
Share this question
or