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. Image for the cookie policy date

Grid multi-select, initialize with multiple selected

I'm trying to use the enableSimpleMultiRowSelection of the GridComponent, and want to select rows initially for my component when it renders. 

There is a selectedRowIndex which only selects 1 row according to the docs. How do I select multiple, do I have to use the underlying Javascript functionality with a databound callback?

1 Reply

TS Thavasianand Sankaranarayanan Syncfusion Team May 13, 2019 01:39 AM

Hi KEVIN, 

Greetings from Syncfusion support. 

Based on your query we suspect that you want to select multiple record in Grid when load the Grid initially. So, we suggest you to use the below code example to achieve your requirement. 

[index.js] 

import { render } from 'react-dom'; 
import './index.css'; 
import * as React from 'react'; 
import { GridComponent, Grid, ColumnsDirective, ColumnDirective, Toolbar, ColumnChooser, Inject, Page  } from '@syncfusion/ej2-react-grids'; 
import { data } from './data'; 
import { SampleBase } from './sample-base'; 
export class ColChooser extends SampleBase { 
 
    dataBound(){ 
      this.selectedRowIndices = [1,2,4]; 
      this.gridInstance.selectRows(this.selectedRowIndices); 
    } 
    constructor() { 
        super(...arguments); 
 
        this.settings = { mode: 'Row', type: 'Multiple'}; 
     
 
    } 
 
    render() { 
        return (<div className='control-pane'> 
    <div className='control-section'> 
        <GridComponent dataSource={data} ref={grid => 
            this.gridInstance = grid} dataBound={this.dataBound.bind(this)}  allowPaging={true} selectionSettings={this.settings} > 
            <ColumnsDirective> 
 
                  ----- 
 
            </ColumnsDirective> 
            <Inject services={[Page]} /> 
        </GridComponent> 
    </div> 
</div>); 
    } 
} 

  
We have prepared a simple sample in the following stackblitz link. 


Refer the help documentation. 



Regards, 
Thavasianand S. 


Loader.
Live Chat Icon For mobile
Up arrow icon