How to add a checkbox to a cell

Hi,

I need to add a checkbox to a cell in react grid, the checkbox must return a boolean value and must be false by default, in other words not checked

Any help would be appreciated

Thank you


1 Reply

MS Manivel Sellamuthu Syncfusion Team August 5, 2021 12:52 PM UTC

Hi Eric, 

Greetings from Syncfusion support. 

From your query we suspect that you want to render the checkbox in the Gird cells with default value as false. You can achieve this requirement by using the columnTemplate feature of the Grid. 
Please refer the below code example and sample for more information. 

. . . 
import { CheckBoxComponent } from '@syncfusion/ej2-react-buttons'; 
 
export class Default extends SampleBase { 
 
  checkboxTemplate (args) { 
    return (<CheckBoxComponent checked={false} ></CheckBoxComponent> 
            ); 
  } 
 
  render() { 
    return ( 
      <div className="control-pane"> 
        <div className="control-section"> 
          <GridComponent dataSource={orderDetails} height="350"> 
            <ColumnsDirective> 
               . . . 
             <ColumnDirective 
             headerText="checkbox" 
             template={this.checkboxTemplate.bind(this)} 
                width="150" 
              /> 
            </ColumnsDirective> 
          </GridComponent> 
        </div> 
      </div> 
    ); 
  } 
} 
 
render(<Default />, document.getElementById('sample')); 


More information about EJ 2 CheckBox can be found in the below  documentation link. 



To proceed further on your requirement, please ensure the below details 

  1. Do you want the checkbox to be rendered based on the data source values or only for display?
  2. the checkbox must return a boolean value” – this query, do you want to render the checkbox while editing (single click or double click)
  3. Do you want to update the row value based on the checkbox change.
  4. Please share your exact your requirement.

Regards, 
Manivel 


Loader.
Up arrow icon