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

Ajax Expand/Collapse details

3 Answers 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jana
Top achievements
Rank 1
Jana asked on 20 Aug 2010, 07:00 PM
What is the best approach for using a telerik grid control and ajax binding to expand/contract additional columns - showing one or two columns in the grid view and displaying the rest of the columns when the row is selected? The Master-Detail example shows how to display child-related tables, but I just need the remaining columns of the main table displayed in a list view rather than grid view.

3 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 24 Aug 2010, 03:30 PM
Hello Jana,

In order to achieve your goal, you can add an ajax setting where the RadGrid updates the RadListView. Then set the EnablePostBackOnRowClick property in the grid ClientSettings to true. Handle the postback in the ItemCommand event of the grid as below:

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if(e.CommandName == "RowClick")
    {
        //code for updating the RadListView here
    }
}

Check it out and let me know if further questions arise.

Sincerely yours,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jana
Top achievements
Rank 1
answered on 25 Aug 2010, 01:59 PM
Before I saw this answer, I discovered a way to use grouping combined with a template, which comes close to accomplishing what I need, if I could find a way to default all the groups to being collapsed initially. Is there a way to do that with the MVC grid? I just have a group for each record which expands and collapses.
 
<%= Html.Telerik().Grid(Model) 
.Name("Grid") 
.Columns(columns =>{columns.Bound(i => i.Title)
.ClientTemplate("<#= Acronym #>"  
+ "</br>"   
+ "<#= Title #>"   
+ "</br>"   
+ "<#= Description #>"   
+ "</br>"   
+ "<#= Keywords #>" 
+ "</br>"  ;   
}) 
.Groupable(grouping => grouping.Groups(groups => 
{groups.Add(i => i.Title);}) ) 
.DataBinding(d => d.Ajax().Select("_AjaxBinding", "Home"))   
.Pageable(paging => paging.PageSize(20) 
.Sortable(sorting => sorting 
.OrderBy(sortOrder => sortOrder.Add(i => i.Title).Ascending() ) ) 
.Scrollable(scrolling => scrolling.Height(550) ) 
.Filterable()
%>
0
Iana Tsolova
Telerik team
answered on 26 Aug 2010, 01:48 PM
Hi Jana,

For the groups to be collapsed in initial load, you can set the GroupsDefaultExpanded property of the grid MasterTableView to false.
Try it out and see if it works for you.

Kind regards,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Jana
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Jana
Top achievements
Rank 1
Share this question
or