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

Group One Column at a Time

2 Answers 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
steve_ba14
Top achievements
Rank 1
steve_ba14 asked on 14 May 2012, 09:18 AM
Good Morning,

Does anyone know of a way to limit the grouping of a Grid.

I have a complex dataset which fails when a second grouping is added to the Grid. I would like to enable grouping but force the user to only group by one column at a time.

Any Ideas?

Steven

2 Answers, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 14 May 2012, 09:28 AM
Hi Steven,

What you can do is to use the OnDataBinding event. If the groups object provided by the Grid client object are more than one then you prevent the event.
e.g.
function onDataBinding(e)
{
    if($("#YourGrid").data('tGrid').groups.length > 1 )
    {
        e.preventDefault();
    }
}

I hope this helps.

Greetings,
Petur Subev
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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
steve_ba14
Top achievements
Rank 1
answered on 14 May 2012, 02:33 PM
Thanks for the code.

However, preventing the grouping by blocking the onDataBinding event still leaves the UI out of sync. (I.E. the last prevented grouping is still visible on the grouping bar).

Is there an easy way to fix this also?

Cheers

Steven

Edit

I have added the line 

  $(".t-group-delete").last().click()

and it works okay. 
Tags
Grid
Asked by
steve_ba14
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
steve_ba14
Top achievements
Rank 1
Share this question
or