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

[Solved] SelectedItem in detailtables and nestedviewtemplate

4 Answers 282 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeroen Eikmans
Top achievements
Rank 1
Jeroen Eikmans asked on 10 Sep 2009, 12:18 PM
Hi,

I have a radgrid set up with detailtables and nestedviewtemplate.

The markup (without all the details...) looks like this :
<telerik:radgrid ...> 
  <DetailTables> 
    <telerik:GridTableView ...> 
      <DetailTables> 
        <telerik:GridTableView ...> 
          <NestedViewTemplate> 
            <telerik:RadTabStrip ...> 
            </telerik:RadTabStrip> 
            <telerik:RadMultiPage ...> 
              <telerik:RadPageView ...> 
                <telerik:RadGrid ...> 
                  <DetailTables> 
                    <telerik:GridTableView ...> 
                      <DetailTables> 
                        <telerik:GridTableView ...> 
                        </telerik:GridTableView> 
                      </DetailTables> 
                    </telerik:GridTableView> 
                  </DetailTables> 
                </telerik:RadGrid> 
              </telerik:RadPageView> 
            </telerik:RadMultiPage> 
          <NestedViewTemplate> 
        </telerik:GridTableView   
      </DetailTables> 
    </telerik:GridTableView   
  </DetailTables> 
</telerik:radgrid> 

I would like to have all parent rows, of the row the user left or right-clicks,selected.
In my code-behind i have code in the ItemCommmand event that when a user expands a row e.Item.Selected is set to true.
So that row is selected, but i also would like the parent rows to be selected and all other rows deselected.

We have the Office2007 skin (very nice one by the way!!) and selected rows are displayed in orange. The reason we want the parent rows selected as well is to make it easer for the user to see where he "is" in the hierarchial grid.

Does anybody know what i need to do to make this work? I think i have to set each grid (the grids in the NestedViewTemplate as well) to multiselect. And then catch the left or right mouseclick, loop through each parent control and clear all selected items if the parent is a grid and if it is a griditem the set selected to true?

4 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 15 Sep 2009, 05:41 PM
Hi Roel,

Please, find attached a sample that demonstrates the described scenario.

I hope it helps.

Regards,
Tsvetoslav
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
Jeroen Eikmans
Top achievements
Rank 1
answered on 17 Sep 2009, 09:43 AM
Hi Tsvetoslav,

thanks for the sample, it does help but i do have some problems with the implementation.
This is since i would like to select the items client-side. So i hook up the onRowClick clientevent and have this code :
function RowClick(sender, eventArgs) {  
    var ownerTable = eventArgs.get_tableView();  
    var item = eventArgs.get_gridDataItem();  
    if (ownerTable != null && item != null) {  
        ownerTable.clearSelectedItems();  
        while (item != null)  
        {  
            item.set_selected(true);  
            item = item.get_owner().get_parentRow();  
        }  
    }  
 The item = item.get_owner().get_parentRow();  isn't the same as the item.OwnerTableView.ParentItem; line from your sample.

I couldn't find what client method i need to use to do the same thing. Can you please tell me how to get the ownertableview and it's parentitem using client-side code?

Another thing is that i also need to clear the selecteditems of grids that are in the nestedview. I'm thinking i need to call get_nestedViews() of the dataitem and then i need to get to the radgrid on the active pageview. I've looked in the radgrid client-side api but i can't find a method i could use for this.

Thanks in advance for your help!!

Kind regards.
0
Jeroen Eikmans
Top achievements
Rank 1
answered on 17 Sep 2009, 03:18 PM
Hi,

I've been searching all day in the source-code and JS-files of the radgrid to find out how i can find all parent dataitems, but with no luck so far.
The item.get_owner() does give me the ownerTableView of the gridDataItem but getting the but i can't find the right way to get the parent DataItem of that ownerTableView (it isn't the mastertableview, that one is one level above it)
I've tried all sorts of client-side API calls but (probably) not the one i really need.

If someone can help me with the proper way to move through a hierarchy grid with client-side code, that would make me very happy :D
0
Tsvetoslav
Telerik team
answered on 23 Sep 2009, 07:19 AM
Hello Roel,

Attached is a modified version of the sample that contains an implementation of the row selection client-side.

Regards,
Tsvetoslav
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
Jeroen Eikmans
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Jeroen Eikmans
Top achievements
Rank 1
Share this question
or