Checkbox changes not firing toolbarClick event

Hello, I've tried adding a custom checkbox to the toolbar using ej2-buttons. The checkbox appears but has no handlers attached to it when I click on it. How do I also allow an input to fire the toolbarClick event?

Here's the basics of my code:

```javascript

import { GridComponent, Toolbar, ToolbarItems } from '@syncfusion/ej2-react-grids';
import { CheckBox } from '@syncfusion/ej2-buttons';

function App() {

  const templateCheckbox = new CheckBox({ label: 'Click', checked: false })

  const toolbarOptions = [

    { type: 'Input', template: templateCheckbox, id: 'show-archived' },

  ]

  const toolbarClick = (args) => {

    console.log(args)

  }

  return (

    <GridComponent toolbarClick={toolbarClick}>

      ...data

    </GridComponent>

  )

}

```


3 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team February 9, 2022 10:10 AM UTC

Hi Andy,  
 
Thanks for contacting Syncfusion support.  
 
Query: “ The checkbox appears but has no handlers attached to it when I click on it. How do I also allow an input to fire the toolbarClick event? 
 
We suggest you to achieve your requirement using change event of CheckBox component. Instead of Grid toolbarClick event, we have suggested you to define the change event to CheckBox component and handle the action inside it.  
 
Refer the below code example. 
 
const templateCheckbox = new CheckBox({ 
      label: 'Click', 
      checked: false, 
      change: this.onChange.bind(this), 
    }); 
 
     
  } 
  onChange(args) { 
    //will be triggered when changing the state of checkbox in grid toolbar 
    debugger; 
  } 
 
   
Refer the below sample for your reference 
 
 
Please get back to us if you have further queries. 
 
Regards, 
Vignesh Natarajan 


Marked as answer

AN Andy February 11, 2022 11:28 PM UTC

Okay great thanks for this I'll try it out.



RR Rajapandi Ravi Syncfusion Team February 14, 2022 05:13 AM UTC

Hi Andy, 

We will wait to hear from you. 

Rajapandi R 


Loader.
Up arrow icon