Hi there,
is it possible to achieve having a grid with two checkbox columns so that the user does not have to place the row into edit mode to tick the checkboxes?
I tried adding them as below and the behavior of the grid when ticking items was strange.
I tried the following definition for the columns:
columns: [
{ field: 'IsSelected', type: "checkbox", width: 50 },
{ field: 'IsSelected2', type: "checkbox", width: 50 },
{ field: 'FullName', headerText: 'FullName' },
],
Also on a different matter (JS + Grid again though) If I define a grid column with "width: 100, minWidth: 100, maxWidth:100"
When the grid initially renders the column width gets set to a default that doesn't respect the minimum and maximum or the specified width as it gets set to a width proportionate to the width of the grid.
I hope that my explanation of the problems is clear.
Cheers James
|
{
field: 'Verified',
displayAsCheckBox: true, // render the checkbox in the Column
editType: 'booleanedit', // render the checkbox to edit a cell
width: 100,
}
|
Hi Rajapandiyan,
Query #1: If I use the booleanEdit and displayAsCheckBox then the user will have to put the row into edit mode to change the values of the checkboxes. Is there any way that the checkboxes could be ticked\unticked without having to edit and update? (The same as you can do with a single column of type = checkbox)
Query #2: I am setting the desired width of the column "width: 100, minWidth: 100, maxWidth:100" so I would have expected that column to be 100px and for the columns that didn't have a width specified to be the ones that adjusted in width.
Cheers James
|
[index.js]
var grid = new ej.grids.Grid({
dataSource: data,
columns: [
{
field: 'OrderID',
headerText: 'Order ID',
width: 'auto',
minWidth: 100,
isPrimaryKey: true,
textAlign: 'Right',
},
{
field: 'Verified1',
template: '<input class="checkboxfield" type="checkbox">',
width: 150,
},
],
queryCellInfo: queryCellInfo,
});
grid.appendTo('#Grid');
function queryCellInfo(args) {
if (args.column.field == 'Verified1' || args.column.field == 'Verified2') {
var checkbox = new ej.buttons.CheckBox({
checked: args.data[args.column.field],
change: checkboxChange,
});
// Render initialized CheckBox.
checkbox.appendTo(args.cell.querySelector('.checkboxfield'));
}
}
function checkboxChange(args) {
var rowInfo = grid.getRowInfo(args.event.target.closest('td'));
var updatedData = rowInfo.rowData;
updatedData[rowInfo.column.field] = args.checked; // modify the row data
grid.updateRow(rowInfo.rowIndex, updatedData); // updateRow(rowIndex,data)
}
|
Hi Rajapandiyan,
both suggestions worked a treat :)
Thank you very very much