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

Grouping pages rad grid

7 Answers 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 11 Sep 2019, 09:46 AM

Hi 

Is there a way of putting grouping together on one page instead spreading over multiple pages in a rad grid ? 

Regards

Alex

7 Answers, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 16 Sep 2019, 07:27 AM

Hi Alex,

RadGrid looks for the items/rows whether its inside the group, and when they reach the number defined in the PageSize (default: 10) it will render the following 10 items on the next page.

To have all the groups on a single page, you will need to disable paging. You can also do that conditionally when there is actually Grouping done for the Grid. Thus the items will have paging in General, and when grouped, they will appear on one page.

Kind regards,
Attila Antal
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Alex
Top achievements
Rank 1
answered on 16 Sep 2019, 12:33 PM

Hi Attila 

Thanks for the answer to my last question 

I have got another one , is it possible to get the group/ungroup option in the header context menu , so that I can turn paging on/off?

Alex

0
Attila Antal
Telerik team
answered on 18 Sep 2019, 07:04 PM

Hi Alex,

Once the Grouping and ContextMenu has been enabled for the Grid, you will be able to Group/Ungroup columns from the ContextMenu. Check out the Grid - Excel-like Filtering demo which has a context menu and you can use it to Group/Ungroup columns.

Kind regards,
Attila Antal
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Alex
Top achievements
Rank 1
answered on 25 Sep 2019, 02:19 PM

Hi Attilla

I have attached a onitemclick on the context menu and when you click the group by the event does not fire.

Is it done on client side? and what is the best way of doing it ?

Regards

Alex

0
Attila Antal
Telerik team
answered on 30 Sep 2019, 10:19 AM

Hi Alex,

The menu embedded in RadGrid handles will skip attaching the ItemClick handler to items that have a specific purpose, such as Group/UnGroup. Items that have a sub menu and they do not need the Click handler would fire.

Nevertheless, if you want to attach a click event listener to the items, you can try using the following example:

<script type="text/javascript">
    function OnHeaderMenuShowing(sender, args) {
        var menu = args.get_menu();
        $(menu.get_element()).find('ul.rmLevel1 > li.rmItem:not(.rmSeparator)').on('click', ItemClickHandler);
    }

    function ItemClickHandler(e) {
        // do something
    }
</script>

 

You can also take advantage of the Command client-side event of the Grid which fires when a command is initiated by the user on client:

<telerik:RadGrid ID="RadGrid1" runat="server">
    <ClientSettings>
        <ClientEvents OnCommand="OnCommand" />
    </ClientSettings>
</telerik:RadGrid>

 

JavaScript

function OnCommand(sender, args) {
    // do something
}

 

Kind regards,
Attila Antal
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Alex
Top achievements
Rank 1
answered on 07 Oct 2019, 03:18 PM

Hi Attila 

Here is my javascript code but everytime I run it, the 'group by' option doesn't turn off the paging feature even though I have specifically stated for it to be set to false. Is there a way to remove the paging feature when the radgrid is grouped by a particular column so all of the rows load as one page instead of multiple.

  function OnCommand(sender, args) {
            var result = args.get_commandName();
            var tableView =sender.get_masterTableView();
            if (result == "GroupByColumn") {
                tableView.AllowPaging = false;
                tableView.PageSize = 400;
            }
            return false;
       
        }

0
Attila Antal
Telerik team
answered on 10 Oct 2019, 09:07 AM

Hi Alex,

The AllowPaging property is for enabling-disabling paging on the server-side. 

To enable/disable the Paging from the client, you will need to fire a command that will do a Post Back, and during that time disable the Paging.

Fire a custom command using the fireCommand, then, on the server use the ItemCommand event handler to capture that custom command.

Example:

JavaScript:

function FirePageCommand() {
    var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
    masterTable.fireCommand("MyCustomCommand", "SomeArgumentsToPassToServer");
}

 

C# - Code behind:

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if(e.CommandName == "MyCustomCommand")
    {
        object arguments = e.CommandArgument; // output: "SomeArgumentsToPassToServer"
    }
}

 

Kind regards,
Attila Antal
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Alex
Top achievements
Rank 1
Share this question
or