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

Persisting Expanded/Collapsed groups.

1 Answer 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 21 Mar 2011, 03:31 PM
I would like to know if it's possible to persist expanded or collapsed groups on postback.

Basically whenever I set a filter or start editing a record a postback occurs and all the groups are set to default (expanded).

Here's my grid code.

    <telerik:RadGrid ID="timesheetGrid" runat="server" GridLines="None" Skin="Windows7"
        AllowSorting="True" ShowGroupPanel="True" AutoGenerateColumns="False" AllowPaging="True"
        PageSize="15" ShowStatusBar="True" AllowFilteringByColumn="True" AllowMultiRowSelection="True"
        OnNeedDataSource="timesheetGrid_NeedDataSource" OnPreRender="timesheetGrid_PreRender"
        ViewStateMode="Enabled" HeaderStyle-HorizontalAlign="Center" OnEditCommand="timesheetGrid_EditCommand">
        <ClientSettings EnableRowHoverStyle="true" AllowColumnsReorder="True" ReorderColumnsOnClient="True"
            AllowDragToGroup="True">
            <Selecting AllowRowSelect="True" />
            <ClientEvents OnRowDblClick="RowDblClick" />
        </ClientSettings>
        <MasterTableView DataKeyNames="ID" EditMode="EditForms">
            <RowIndicatorColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
            <Columns>
                <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" />
                <telerik:GridBoundColumn DataField="ID" HeaderText="ID" UniqueName="ID" Visible="True"
                    ReadOnly="true" FilterControlWidth="30px" HeaderStyle-Width="50px">
<HeaderStyle Width="50px"></HeaderStyle>
                </telerik:GridBoundColumn>
                <telerik:GridDateTimeColumn DataField="Date" DataType="System.DateTime" HeaderText="Date"
                    UniqueName="DateFrom" ReadOnly="true" DataFormatString="{0:dd/MM/yyyy}" AllowFiltering="false"
                    HeaderStyle-Width="75px">
                    <HeaderStyle Width="75px"></HeaderStyle>
                </telerik:GridDateTimeColumn>
                <telerik:GridBoundColumn DataField="User.UserName" HeaderText="User" UniqueName="User"
                    ReadOnly="true">
                </telerik:GridBoundColumn>
                <telerik:GridNumericColumn UniqueName="Duration" HeaderText="Duration (Hrs)" DataType="System.Double"
                    DataField="Duration" FilterControlWidth="50px">
                    <HeaderStyle Width="80px"></HeaderStyle>
                    <ItemStyle HorizontalAlign="Right" />
                </telerik:GridNumericColumn>
                <telerik:GridBoundColumn DataField="ShortDescription" HeaderText="Description" UniqueName="Description">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="DocketNo" HeaderText="Docket No" UniqueName="DocketNo"
                    ReadOnly="true" FilterControlWidth="50px" HeaderStyle-Width="70px">
<HeaderStyle Width="70px"></HeaderStyle>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="FileCode" HeaderText="FileCode Name" UniqueName="FileCode"
                    HeaderStyle-Width="100px" FilterControlWidth="60px">
<HeaderStyle Width="100px"></HeaderStyle>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="FileCodeID" HeaderText="FileCode ID" UniqueName="FileCodeID"
                    Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CostCenter" HeaderText="Cost Center" UniqueName="CostCenter"
                    HeaderStyle-Width="70px" FilterControlWidth="40px">
<HeaderStyle Width="70px"></HeaderStyle>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CostCenterID" HeaderText="Cost Center ID" UniqueName="CostCenterID"
                    Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CompanyID" HeaderText="Company ID" UniqueName="CompanyID"
                    Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridCheckBoxColumn DataField="IsOvertime" DataType="System.Boolean" HeaderText="Overtime"
                    UniqueName="Overtime" ReadOnly="true">
                </telerik:GridCheckBoxColumn>
            </Columns>
            <EditFormSettings UserControlName="UserControls/TimesheetEdit.ascx" EditFormType="WebUserControl">
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
        <PagerStyle Mode="NumericPages" VerticalAlign="Bottom" />
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
        <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Windows7">
        </HeaderContextMenu>
    </telerik:RadGrid>


Thanks in advance.

Daryl

1 Answer, 1 is accepted

Sort by
0
Accepted
Pavlina
Telerik team
answered on 21 Mar 2011, 03:46 PM
Hi Daryl,

Here is a code library submission which explains how to retain the Groups Expanded State on Rebind using server side approach. Go through it and see if it meets your requirement.
Persist Groups Expanded State on Rebind

Best wishes,
Pavlina
the Telerik team
Tags
Grid
Asked by
Alan
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or