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

Selected Row Template

5 Answers 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ManniAT
Top achievements
Rank 2
ManniAT asked on 11 Mar 2009, 09:36 AM

Hi,

I'm not sure if this is the right place to aks this - so feel free to move the post to "feature request" or where ever you like to.

My question is about a "selected row template".
The idea comes from the MS WPF datagrid control (WPF toolkit).

There is a way to customize the "selected row".

 

So what I think about is - I have data with (let's say) 30 columns.

I want to display 6 of them in the "normal" grid view.

When the user selects a row - I want to display it "expanded" showing the values on the other 24 columns.

 

I mean something like the EditItemTemplate - but not for editing - just to display more information about a selected dataitem.

Are you thinking about such a thing? Or has this to be solved in code behind?

Regards

Manfred

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 11 Mar 2009, 10:08 AM
Hello Manfred,

Until the Telerik Team creates such a buit-in feature  you can try out the same scenario using NestedViewTemplate, as shown in the demo link below:
NestedView template

In addition to this, you can hide the ExpandCollapseColumn and set the EnablePostBackOnRowClick property of the grid to true. Then on clicking the row expand/collapse the row to display/ hide details. Check out the code below to understand better:
aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server"  OnItemCommand="RadGrid1_ItemCommand" OnColumnCreated="RadGrid1_ColumnCreated" > 
   <ClientSettings EnablePostBackOnRowClick="true" > 
       <Selecting AllowRowSelect="True" /> 
   </ClientSettings> 
 <MasterTableView Name="Master" DataSourceID="SqlDataSource1" > 
        <NestedViewTemplate >         
             
       </NestedViewTemplate> 
        ..... 
  

cs:
  // To hide the expandcolumn 
  protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) 
    { 
        if (e.Column.UniqueName == "ExpandColumn"
            e.Column.Visible = false
    } 
 protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "RowClick"
        { 
            GridDataItem dataItem = (GridDataItem)e.Item; 
            dataItem.Expanded = !dataItem.Expanded; 
 
        } 
    } 
  

-Princy.
0
ManniAT
Top achievements
Rank 2
answered on 11 Mar 2009, 10:13 AM
Hi,

thank you for the fast answer.

What I forgot to explain in my question - is that I want to use the thing with Master/Detail grids.
So expanding would show my details also - what I want to avoid.

As long as you have not detail rows the solution (I'v seen the sample before) is great and easy to do, you are right.

Any suggestions with M/D and "NestedView"?
It would even be OK that (for an example) the nestedview has the expand column for the detail tables.

Regards

Manfred
0
Sebastian
Telerik team
answered on 13 Mar 2009, 03:50 PM
Hi Manfred,

You can utilize the nested view template as shown in this online demo of the grid:
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/nestedviewtemplate/defaultcs.aspx

or consider using global item template for the master table rows as demonstrated here:
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/cardview/defaultcs.aspx

Note that you may include a hidden panel at the bottom of the item template with custom expand functionality if you prefer this type of layout.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
ManniAT
Top achievements
Rank 2
answered on 13 Mar 2009, 04:03 PM
So you suggest to implement a "collapsed" thing which gets expanded when a user selects a row if I understand you correct?
And collapse it again when the row gets unselected, or when the row gets edited.
Re-Expand it when the grid gets refreshed and the row is still selected.
Handle paging...

I guess the means a lot of work - and that's the reason why I ask for this as a feature :)
Because I used this with the MS-WPF Grid where it means nothing more than a simple template for the "selected situation".
The rest is done by the framework.

Anyhow - thanks for the purposes

Manfred
0
Sebastian
Telerik team
answered on 07 Apr 2009, 04:29 PM
Hello Manfred,

Actually the implementation requires only several lines of javascript/ code-behind logic in order to attain the requested functionality with NestedView template for detail info. For your convenience I am attaching a sample web site which illustrates the approach in question.

Best regards,
Sebastian
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
ManniAT
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 1
ManniAT
Top achievements
Rank 2
Sebastian
Telerik team
Share this question
or