Radgrid collapse not working.

12 posts, 0 answers
  1. Neil
    Neil avatar
    9 posts
    Member since:
    Oct 2010

    Posted 18 Oct 2010 Link to this post

    Hi!
    Due to some requirements the datasource in the nestedviewtemplate are supplied programmatic in the ItemCommand,
    everything works fine when expanding and the data are loaded but when I click collapse the selected row won't collapse and instead it just post back and displays the same-thing.
    Is there a way to programmatically collapse the nestedview of a selected row when collapse is clicked?
    Also I'm not allowed to use sqldatasource because the data is from List<T>.

    Thanks!
  2. Neil
    Neil avatar
    9 posts
    Member since:
    Oct 2010

    Posted 19 Oct 2010 Link to this post

    Also, collapse is not working when HierarchyLoadMode="ServerOnDemand";
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 19 Oct 2010 Link to this post

    Hi Neil,

    Try using Advanced DataBinding for the grid in NestedViewTemplate. Attach OnNeedDataSource event to grid and write the code for populating grid in the event handler, instead of trying in ItemCommand event. Please checkout the demo which demonstrates how to use Advanced DataBinding.
    Advanced Data Binding

    Kind regards,
    Pavlina
    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
  5. Neil
    Neil avatar
    9 posts
    Member since:
    Oct 2010

    Posted 19 Oct 2010 Link to this post

    Hi Pavlina,

    I've already done that but it has a problem, the data in the nested view wont show up unless I bind the radgrid.
    And as we all know we cannot call Bind after the OnNeedDataSource.
    (Please Note that inside the nested view are asp:details view that are binded to the source)

    Thanks!
  6. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 20 Oct 2010 Link to this post

    Hi Neil,

    If the issue persists, it will be best if you send us a small runnable project which demonstrates the issue. Thus we will be able to we debug the project and provide you with more to-the-point answer.

    Greetings,
    Pavlina
    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
  7. rosborn
    rosborn avatar
    1 posts
    Member since:
    Apr 2007

    Posted 01 Nov 2010 Link to this post

    I'm also interested in the solution, as I'm having the same problem.
  8. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 03 Nov 2010 Link to this post

    Hello Roger,

    Can you make sure that EnableViewState property of the grid is set to true? Please take into account that some operations in Telerik RadGrid like data extraction through the ExtractValuesFromItem method, grouping, hierarchical views expand/collapse, custom edit forms or filtering require that view state is enabled.

    All the best,
    Pavlina
    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
  9. Niraj
    Niraj avatar
    23 posts
    Member since:
    Nov 2010

    Posted 07 Jan 2011 Link to this post

    .
  10. aaron
    aaron  avatar
    2 posts
    Member since:
    Mar 2011

    Posted 05 Nov 2011 Link to this post

     private void CollapseAll()
        {
            foreach (GridItem item in radGridDocument.MasterTableView.Controls[0].Controls)
            {
                if (item is GridGroupHeaderItem)
                {
                    item.Expanded = false;
                }
            }
        }
        private void ExpandAll()
        {
            foreach (GridItem item in radGridDocument.MasterTableView.Controls[0].Controls)
            {
                if (item is GridGroupHeaderItem)
                {
                    item.Expanded = true;
                }
            }
        }


    This is the code i am using on click event,but even though grid is not getting collapse.
  11. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 09 Nov 2011 Link to this post

    Hello Aaron ,

    Please follow the approach from the code library below in order to implement the desired functionality and see if it works as expected.
    Custom expand/collapse column with ExpandAll/CollapseAll image button in the header

    I hope this helps.

    All the best,
    Pavlina
    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
  12. Baiju
    Baiju avatar
    1 posts
    Member since:
    Sep 2013

    Posted 01 Mar Link to this post

    I also have the same issue and resolved it.

    For resolving the issue , i used two hidden fields

         <asp:HiddenField ID="hdnExpandCollapse" Value="0" runat="server" />

         <asp:HiddenField ID="hdnExpanded" Value="0" runat="server" />

    Then the following two grid events are used to capture the state of the grid item

             /* Start functions used for collapse the grid  */
            protected void Grid_PreRender(object sender, EventArgs e)
            {
                int i = 0;
                foreach (GridDataItem item in Grid.MasterTableView.Items)
                {
                     GridTableView DetailsTable = (GridTableView)item.OwnerTableView;
                 
                     System.Collections.Hashtable ht = DetailsTable.DataKeyValues[i];


                    string strDataKey= ht["DataKey"].ToString();
                    if (strDataKey == hdnExpandCollapse.Value)
                         {
                             if (hdnExpanded.Value == Territory)
                             {
                                 item.Expanded = false;
                                 hdnExpanded.Value = "0";
                             }
                             else
                             {
                                 item.Expanded = true;

                                 hdnExpanded.Value = Territory;
                             }

                         }
                         
                         i++;
                }
            }


            protected void Grid_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
            {
                if (e.CommandName == RadGrid.ExpandCollapseCommandName)
                {
                    hdnExpandCollapse.Value = ((EntityClass)(e.Item.DataItem)).DataKey.ToString();

                }
            }
            /* End functions used for collapse the grid  */

  13. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 01 Mar Link to this post

    Hello Baiju,

    Thank you for sharing your solution with the community.

    Regards,
    Pavlina
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017