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

[Solved] Radgrid expand/collapse rows option

1 Answer 457 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Harini
Top achievements
Rank 1
Harini asked on 13 Mar 2013, 05:03 AM
Hi,
I using VS2012. I am using a telerik radgrid and binding the grid to customer information in a dataset(single dataset). A single customer can have many records in the dataset. Hence in my grid i want to have my first column as a expand-collapse button '(+)' column. If a single customer is getting repeated in the dataset (which i get to know from the 'customer name' column and thier unique 'customer ID' column in the dataset), i want to  display the (+) expand button, on click of expand i want to display the other records for this same customer, and on clicking collapse(-) button i want to show only one record for that customer. If the customer name is unique in the dataset then i dont want to display the expand-collapse button in the first column. Is there any way to do this ? Kindly help. Thanks in Advance.

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 15 Mar 2013, 03:28 PM
Hello,

 You will require custom server-side code to achieve this requirement. For example you can use GridButtonColumn or GridTemplateColumn to show the expand / collapse buttons in the grid. Then on button click you fire a custom command and rebind the control to show the new data. Here is a short sample:

<Columns>
                        <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="customExpandCollapseCommand" ImageUrl="expandButton.jpg"></telerik:GridButtonColumn>
                    </Columns>
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName=="customExpandCollapseCommand")
        {
            RadGrid1.DataSource = newDataSource;
            RadGrid1.Rebind();
        }
    }

Regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Harini
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or