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

Expand/Collapse group headers not working for grid

1 Answer 102 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Damodar
Top achievements
Rank 1
Damodar asked on 13 Mar 2012, 05:13 PM
Hi,

I am using the following mark up for a feature in my application with expandable group headers, so that i can hide and show accordingly via expand/collapse link button. The mark up for the grid is as below:

        <telerik:RadGrid ID="m_UIExperienceGrid" runat="server" SkinID="RecruitmentGrid_NoHeaders" CssClass="SimpleGrid summary"
            AllowMultiRowSelection="false" OnItemDataBound="OnExperienceGridItemDataBound">
            <MasterTableView AutoGenerateColumns="false" GroupLoadMode="Client" EditMode="InPlace">   
                <GroupByExpressions>
                    <telerik:GridGroupByExpression  >
                        <SelectFields>
                            <telerik:GridGroupByField FieldName="GroupIndexName"  />
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldName="GroupIndexName" />
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                </GroupByExpressions>
                <GroupHeaderItemStyle CssClass="listItem" />   
                <Columns>
                        <telerik:GridTemplateColumn>
                            <ItemTemplate>       
                                <div class="itemText"><%#Eval("JobDescription") %></div>
                            </ItemTemplate>       
                        </telerik:GridTemplateColumn>   
                </Columns>
            </MasterTableView>   
            <ClientSettings AllowGroupExpandCollapse="true">
                <ClientEvents OnGridCreated="GridCreated" />
            </ClientSettings>               
        </telerik:RadGrid>

The mark up for link button that does the collapse/expand is as below:
        <asp:LinkButton ID="m_UIExpandAllExperiencesLink" runat="server" OnClientClick="return ExpandCollapseAllGroups('rgExpand');"/>

        <asp:LinkButton ID="m_UICollapseAllExperiencesLink" runat="server" OnClientClick="return ExpandCollapseAllGroups('rgCollapse');" />

The java scripts are as below:

    function GridCreated(sender, eventArgs) {
            //collapse all items when page loads
            ExpandCollapseAllGroups('rgCollapse');
        }
       
        //Expands or collapses all group headers based on expandCollapseClass
        function ExpandCollapseAllGroups(expandCollapseClass) {
            var tableView = $find('<%=m_UIExperienceGrid.ClientID %>').get_masterTableView();
            var groupHeaders = $telerik.$(tableView.get_element()).find('INPUT[class="'+ expandCollapseClass +'"]');
            if (groupHeaders.length > 0) {
                for (var i = 0; i < groupHeaders.length; i++) {
                    $telerik.$(groupHeaders[i]).click();
                }
            }
            //return false to prevent postbacks
            return false;
        }

Essentially i leverage the css inbuilt for the telerik grid to do the expand/collpase from the client side.

This worked for me well a few days back, but i am facing issues recently, as per the screenshot attached, i have some comments in them as well. While expanding/collapsing the items is not happening individually too, just the expand/collapse image changes.
I have grid with grouping else where in my appln with server side expansion and collpase which is working fine but in the above scenario, it is not working.

Thanks and regards,
Damodar

1 Answer, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 16 Mar 2012, 10:16 AM
Hi Stayajit,

You could try downloading the latest internal build and observe if the issue still persists.

I tried to replicate the issue which you described, but to no avail. Attached to this message, you will find the code which I used for testing.

Please, take a look at it and let me know if there are any differences at your end, which I may be leaving out.

Greetings,
Antonio Stoilkov
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
Ajax
Asked by
Damodar
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Share this question
or