Hi,
Do you support such a thing like this?
|
<script id="template" type="text/x-template">
<div class="template_checkbox">
${if(Verified === 'Yes')}
<span>Required</span>
${else}
<input class="check-input" type="checkbox">
${/if}
</div>
</script>
<script id="headerTemplate" type="text/x-template">
<div>
<input class="check-input" type="checkbox">
</div>
</script> |
|
let grid: Grid = new Grid({
...
columns: [
{ template: '#template', headerTemplate: '#headerTemplate', field: 'Verified' },
...
],
});
grid.appendTo('#Grid'); |
|
//Grid’s headerCellInfo event handler
function onHeaderCellInfo(args) {
if (args.cell.column.field === 'Verified') {
// EJ2 Checkbox is initialized and appended on the template input element
let checkbox: CheckBox = new CheckBox({
change: onHeaderCheckboxChange.bind(this)
});
var checkboxEle = args.node.querySelector('.check-input');
// Render initialized CheckBox.
checkbox.appendTo(checkboxEle);
}
}
//Grid’s queryCellInfo event handler
function onQueryCellInfo(args) {
if (args.column.field === 'Verified') {
if (args.data["Verified"] === "No") {
// EJ2 Checkbox is initialized and appended on the template input element if the cell value is ‘No’
let checkbox: CheckBox = new CheckBox({
change: onCheckboxChange.bind(this)
});
var checkboxEle = args.cell.querySelector('.check-input');
// Render initialized CheckBox.
checkbox.appendTo(checkboxEle);
}
}
} |
|
// Content checkbox change event
function onCheckboxChange(args) {
// Retrieves current row information
var currentRowInfo = grid.getRowInfo(args.event.target);
// The checkbox value is updated to its corresponding field
// gridInstance.setCellValue(primary key value, column field, updated value)
grid.setCellValue(currentRowInfo.rowData['ID'], 'Verified', 'Yes');
}
// Header checkbox change event
function onHeaderCheckboxChange(args) {
// The checkbox field value is updated for the entire data source
grid.dataSource.forEach(dat => {
var value = (args.checked) ? 'Yes' : 'No';
// The checkbox value is updated to its corresponding field
// gridInstance.setCellValue(primary key value, column field, updated value)
grid.setCellValue(dat['ID'], 'Verified', value);
})
} |