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

RadGrid Grouping, Single Row Expand using Javascript.

1 Answer 193 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott Harrington
Top achievements
Rank 1
Scott Harrington asked on 09 Nov 2010, 08:47 AM
I am using grouping with the RadGrid, everything works great.  However, I'd really like to get single row expand to work when clicking on the header.  What I mean is, when a group header is clicked, I'd like that header to expand, and all it's children stay collapsed.  I've seen this work when GroupLoadMode is set to Server, and this is taken care on the server side.  I'd really like to keep this fix on the client side using Javascript, but I just can't seem to get it to work.  The following code was my best attempt:

function RowClicked(sender)
{
    var grid = $find("<%= rgSpecialOrders.ClientID %>");
    var master = grid.get_masterTableView();
  
    $('#' + sender.parentElement.parentElement.id).each(
        function (i)
        {
            master.collapseItem(i + sender.sectionRowIndex + 1);
        });
}

Unfortunately this did not work?  Do you have any suggestions on how to get this to work while only using Javascript and JQuery?  Thanks a lot for your help!

1 Answer, 1 is accepted

Sort by
0
Scott Harrington
Top achievements
Rank 1
answered on 09 Nov 2010, 05:54 PM
After spending some additional time on this, this morning, I got it, here is the solution I came up with:

var skipExpand = false;
  
function RowExpanding(sender, args)
{
    if (!skipExpand)
    {
        skipExpand = true;
    }
    else
    {
        args._cancel = true;
    }
}
  
function RowClicked(sender)
{
    skipExpand = false;
}

So what is now happening is everytime a row is expanded, the RowExpanded function will be fired for the selected header as well as all of its children.  The top method will cancel every exand but the first expand.  The last function, RowClick(), simply resets the flag so that the method will work the next time a row is expanded.

This is a very simple solution, but it works!  Enjoy!
Tags
Grid
Asked by
Scott Harrington
Top achievements
Rank 1
Answers by
Scott Harrington
Top achievements
Rank 1
Share this question
or