var grid = new ej.grids.Grid({
dataSource: data,
columns: [
{ type: 'checkbox', width: 50 },
{ field: 'Freight', width: 120, format: 'C2', textAlign: 'Right' },
{ field: 'ShipCountry', headerText: 'Ship Country', width: 150 }
],
rowDataBound: (args) => {
if (args.data['Freight'] < 30) {
args.row.getElementsByClassName('e-gridchkbox')[0].classList.add('disablecheckbox');
args.row.getElementsByClassName('e-checkbox-wrapper')[0].classList.add('disablecheckbox')
}
}
});
grid.appendTo('#Grid'); |
.disablecheckbox {
pointer-events: none;
opacity: 0.5;
} |
var grid = new ej.grids.Grid({
dataSource: data,
selectionSettings: { checkboxOnly: true },
columns: [
{ type: 'checkbox', width: 50 },
{ field: 'Freight', width: 120, format: 'C2', textAlign: 'Right' },
],
rowDataBound: (args) => {
if (args.data['Freight'] < 30) {
args.row.getElementsByClassName('e-gridchkbox')[0].classList.add('disablecheckbox');
args.row.getElementsByClassName('e-checkbox-wrapper')[0].classList.add('disablecheckbox')
}
},
checkBoxChange: (args) => {
var customselect = [];
if (args.checked && args.target.classList.contains('e-checkselectall')) {
for (var i = 0; i < args.selectedRowIndexes.length; i++) {
var row = grid.getRowByIndex(args.selectedRowIndexes[i]);
if (!row.querySelector('.disablecheckbox')) {
customselect.push(args.selectedRowIndexes[i])
}
}
grid.selectRows(customselect)
}
}
});
grid.appendTo('#Grid'); |
constructor() {
super(...arguments);
// to diable the checkbox from selection
this.rowDataBound = (args)=>{
if (args.data['Freight'] < 30) {
args.row.getElementsByClassName('e-gridchkbox')[0].classList.add('disablecheckbox');
args.row.getElementsByClassName('e-checkbox-wrapper')[0].classList.add('disablecheckbox')
}
}
// to prevent the disabled checkbox from selection while using selectall checkbox
this.onCheckBoxChange = (args)=>{
var customselect = [];
if (args.checked && args.target.classList.contains('e-checkselectall')) {
for (var i = 0; i < args.selectedRowIndexes.length; i++) {
var row = this.getRowByIndex(args.selectedRowIndexes[i]);
if (!row.querySelector('.disablecheckbox')) {
customselect.push(args.selectedRowIndexes[i])
}
}
this.selectRows(customselect)
}
}
}
render() {
return (<div className='control-pane'>
<div className='control-section row'>
<GridComponent dataSource={orderDataSource} checkBoxChange={this.onCheckBoxChange} selectionSettings={this.selectionsettings} allowPaging={true} ref={grid => this.gridInstance = grid} rowDataBound={this.rowDataBound} pageSettings={{ pageSize: 10, pageCount: 5 }}>
<ColumnsDirective>
……………………………………………………
</ColumnsDirective>
<Inject services={[Filter, Page]}/>
</GridComponent>
</div>
</div>);
}
}
render(<FilterMenu />, document.getElementById('sample'));
|
.disablecheckbox {
pointer-events: none;
opacity: 0.5;
}
|