We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Adding custom menu item to existing list

Thread ID:

Created:

Updated:

Platform:

Replies:

146776 Aug 19,2019 02:40 PM UTC Aug 20,2019 07:35 AM UTC React - EJ 2 1
loading
Tags: Grid
Peter Gelderbloem
Asked On August 19, 2019 02:40 PM UTC

I am looking at this example:
https://ej2.syncfusion.com/15.4.23/documentation/grid/columns.html?lang=typescript#custom-column-menu-item
It looksl ike it overwrites teh defaults and adds one new item.
How do I keep the defaults and add a new item to end?

Pavithra Subramaniyam [Syncfusion]
Replied On August 20, 2019 07:35 AM UTC

Hi Peter, 
 
Thanks for contacting Syncfusion support. 
 
You can achieve your requirement by adding all the default column menu items as shown in the below example with custom items. So that all the default column menu items will be available to the grid with custom ones and only for the custom menu items we have to write the handler function using columnMenuClick event. Please refer to the below code example, documentation link and sample link for your reference, 
 
[index.js] 
export class ColumnMenuSample extends SampleBase { 
  constructor() { 
    super(...arguments); 
    this.groupOptions = { showGroupedColumn: true }; 
    this.filterSettings = { type: "CheckBox" }; 
    this.columnMenuItems = ['AutoFit', 'AutoFitAll', 'SortAscending', 'SortDescending', 'Group', 'Ungroup',’ColumnChooser’,’Filter’, { text: 'Reset', id: 'reset' }]; // default items with custom items 
  } 
 
  columnMenuClick(args) { 
    if (args.item.id === 'reset') { 
      console.log("To do here"); 
    } 
  } 
  render() { 
    return (<div className='control-pane'> 
      <div className='control-section'> 
        <GridComponent id='gridcomp' dataSource={orderDetails} allowPaging={true} allowGrouping={true} allowSorting={true} allowFiltering={true} showColumnMenu={true} groupSettings={this.groupOptions} filterSettings={this.filterSettings} columnMenuItems={this.columnMenuItems} columnMenuClick={this.columnMenuClick.bind(this)}> 
          <ColumnsDirective> 
         .    .   . 
          </ColumnsDirective> 
          <Inject services={[Resize, Group, Sort, ColumnMenu, Filter, Page]} /> 
        </GridComponent> 
      </div> 
    </div>); 
  } 
} 
 
render(<ColumnMenuSample />, document.getElementById('sample')); 
 
 
 
 
Please get back to us if you need any further assistance on this. 
 
Regards, 
Pavithra S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon