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

How to get Detail Table row count from Client Side while Scrolling rows in Master Table.

2 Answers 367 Views
Grid
This is a migrated thread and some comments may be shown as answers.
gc_0620
Top achievements
Rank 1
gc_0620 asked on 19 Aug 2011, 09:51 PM

Folks,

I am using ASP.Net Ajax Q2 2011 with VS 2010. Below is my Grid Table Laout.

        
        Parent Table

                                ---- Detail Table 1 (GridTableView Name = "Detail")

                                             --- Detail Table 1.1

                                ---- Detail Table 2

 
My desired expectations:

1) While I am scrolling rows in Parent Table, I would like to get the row counts of related Detail Table 1 but not row counts of other Detail Tables.

2) Also if I am scrolling rows in Detail Table 1, do nothing.
 

Below works to get the Row Count of Parent Table; but having some difficulty to getting row count of Related Detail Table 1.

function RowCount(sender, args)  
{  
   
    var grid = $find("<%=RadGrid1.ClientID %>");  
    var MasterTable = grid.get_masterTableView();  
    var Rows = MasterTable.get_dataItems();
    // Need Help here to get the Row Count of Detail Table 1 and Pass into TextBox RowCountTextBox...
    alert(Rows.length); 
    document.getElementById("<%=RowCountTextBox.ClientID %>").value = parseInt(Rows.length);
      
 }  

Rad Grid Settings:
'''

 

HierarchyLoadMode = "ServerBind"

 

'''
<ClientEvents OnFilterMenuShowing="filterMenuShowing" OnRowSelected = "RowCount" />
'''
'''
<asp:TextBox ID="RowCountTextBox" runat="server" Text="" Width = "400px"> </asp:TextBox>


I tried in Server Side Prerender event, but did not get the Child Table row count if Parent row is not expanded. 


Thanks

gc_0620

2 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 24 Aug 2011, 11:10 AM
Hi Gc_0620,

To achieve the desired functionality you could try using the following code snippet and let me know if it helps you:
function RowCount(sender, args) {
 
            var grid = $find("<%=RadGrid1.ClientID %>");
            var MasterTable = grid.get_masterTableView();
            var Rows = MasterTable.get_dataItems();
            // Need Help here to get the Row Count of Detail Table 1 and Pass into TextBox RowCountTextBox...
 
            var detailTable1 = Rows[0].get_nestedViews()[0];
            var detailTable1RowsCount = detailTable1.get_dataItems().length;
 
            alert(detailTable1RowsCount);
            document.getElementById("<%=RowCountTextBox.ClientID %>").value = parseInt(Rows.length);
 
        }

Looking forward for your reply.

Greetings,
Radoslav
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
gc_0620
Top achievements
Rank 1
answered on 25 Aug 2011, 08:12 PM
Thanks Radoslav

It works but I had to set  HierarchyLoadMode = "Client"
Tags
Grid
Asked by
gc_0620
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
gc_0620
Top achievements
Rank 1
Share this question
or