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

Disable Aggregates for a single GridNumericColumn

2 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 2
Mike asked on 26 Oct 2016, 03:31 PM

Hi,

I am using the aggregates context menu to allow the user to choose their own aggregate functions, however, 1 particular column should not allow aggregation as each row is potentially showing a value in a different currency.

Is there any way that I can disable aggregates for this column only? There doesn't appear to be any column setting relating to this.

Thanks in advance,
Mike.

2 Answers, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 31 Oct 2016, 01:32 PM
Hello Mike,

You can use the OnHeaderMenuShowing event handler to achieve this requirement:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/client-side-programming/events/onheadermenushowing

Similar to the javascript approach provided here:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/how-to/Filtering/reduce-the-filter-menu-options

You can also check the following code-library or the attached web site sample:
http://www.telerik.com/support/code-library/conditionally-hide-controls-from-excel-like-filtering-menu

I hope this will prove helpful.

Regards,
Eyup
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
0
Mike
Top achievements
Rank 2
answered on 02 Nov 2016, 04:41 PM

Thanks for the links Eyup, following the links you provided I simply hooked up the following to the OnHeaderMenuShowing event and it's now working perfectly.

function ProjectGrid_HeaderMenuShowing(sender, args) {
  var disabledAggregateCols = ["Financial_BudgetCostForeign", "Financial_BudgetSellForeign"];
 
  var colName = args.get_gridColumn().get_uniqueName();
  var filterItem = args.get_menu().findItemByText("Aggregates");
 
  if (disabledAggregateCols.indexOf(colName) >= 0) {
    filterItem.set_enabled(false);
  }
  else {
    filterItem.set_enabled(true);
   }
}
Tags
Grid
Asked by
Mike
Top achievements
Rank 2
Answers by
Eyup
Telerik team
Mike
Top achievements
Rank 2
Share this question
or