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

Javascript for no of rows selected in GridTableView

9 Answers 211 Views
Editor
This is a migrated thread and some comments may be shown as answers.
amol
Top achievements
Rank 1
amol asked on 10 Jun 2008, 11:16 AM
 Hello Everybody,
i have hierarchical structure of RadGrid
for outer grid i got no of checkboxes selected using

grid.MasterTableView.SelectedRows.length

 
 how to find out numbers of checkboxes selected for inner grid ( GridTableView )


Thanks in Advance

Amol

9 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 13 Jun 2008, 08:20 AM
Hello Amol,

You can try this:

$find('RadGrid1').get_detailTables()[index].get_selectedItems().length 

Where "index" is the index of the detail table in RadGrid's detail table collection.


Kind regards,
Veli
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
amol
Top achievements
Rank 1
answered on 17 Jun 2008, 11:20 AM
i want to find out number of rows or checkboxes selected in javascript for

DetailTables

0
Veli
Telerik team
answered on 17 Jun 2008, 12:29 PM
Hi Amol,

The javascript provided below finds the number of selected items in the DetailTables that are visible (rendered). For example:

$find('RadGrid1').get_detailTables()[0].get_selectedItems().length 

The code above finds the number of items selected in the first detail table in RadGrid, which means the highest expanded detail table in the current page of RadGrid. I hope this clarification is helpful.

Best regards,
Veli
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
amol
Top achievements
Rank 1
answered on 19 Jun 2008, 10:34 AM
i have implement your code
it is giving following error
Object doesn't support this property or method

After getting object of DetailTables.
DetailTables have not any propert or method (like .selectedRows) that will give me selected rows

i am using following code to get object of DetailTables

grid.MasterTableView.DetailTables[0]

0
Veli
Telerik team
answered on 19 Jun 2008, 12:02 PM
Hi Amol,

The described methods are the member methods of the older version of RadGrid for ASP.NET client object.The provided sample code refers to the latest RadGrid for ASP.NET AJAX Framework, which this ticket has been marked for. If you are using the older RadGrid for ASP.NET, then you would transform your code to:

window['<%= RadGrid1.ClientID %>'].DetailTablesCollection[0].SelectedRows 

Please note that the DetailTablesCollection has objects inside only if the actual detail tables are generated, which means that it would have length 0 if no item is expanded on ServerOnDemand detail table binding. If your HierarchyLoadMode is set to "Client", however, you will have all your detail tables available in the collection even before expanding.

Kind regards,
Veli
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
amol
Top achievements
Rank 1
answered on 20 Jun 2008, 07:02 AM
Hello Everybody,
                      
                         i am just one step behind solution.when i expand detailsTable
i got proper result using following code.

if

(grid.DetailTablesCollection[0].SelectedRows.length > 0 || grid.MasterTableView.SelectedRows.length > 0){
alert(
"Delete all selected Record's?"); }else{alert("Please Select at least one Record");return false;}

But when i don't exand detailsTable and go with same code it gives me following error. i set HierarchyLoadMode to "Client".

Microsoft JScript runtime error: 'grid.DetailTablesCollection.0.SelectedRows' is null or not an object

how can i know is detailsTable is exanded or not .If i got any boolean value,it will be my solution. 


Thanks in Advance
Amol

0
Veli
Telerik team
answered on 20 Jun 2008, 07:41 AM
Hi Amol,

Please try the following:

if(grid.MasterTableView.SelectedRows.length > 0) 
    if (grid.DetailtablesCollection[0].SelectedRows != null && grid.DetailtablesCollection[0].SelectedRows.length > 0) 
    { 
        alert("Delete all selected Record's?"); 
    } 
    else 
    } 
        alert("Please Select at least one Record");return false
    } 
else 
    alert("Please Select at least one Record");return false

This is to make sure the SelectedRows collection of the detail tables is generated.

Best wishes,
Veli
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
amol
Top achievements
Rank 1
answered on 10 Jul 2008, 12:15 PM
Hello All,

               your code  work, but for using u r code it become neccessery to select outer table entry. Main requirment is that how can i found out grid is expand or not.

grid.DetailtablesCollection[0].SelectedRows 

above code throws error if did not expand DetailTable


Thanks in Advance


Amol
0
Veli
Telerik team
answered on 10 Jul 2008, 12:43 PM
Hello Amol,

If you sent HierarchyLoadMode="Client" for RadGrid, your DetailTablesCollection should not be null even if there are no detail tables shown (all items are collapsed). On the other hand, if you need to use server hierarchy loading, your DetailTablesCollection will hold only the shown detail tables. In this case you can check if the item is expanded using the grid.MasterTableView.Rows[itemIndex].Expanded property.

Regards,
Veli
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Editor
Asked by
amol
Top achievements
Rank 1
Answers by
Veli
Telerik team
amol
Top achievements
Rank 1
Share this question
or