let grid: TreeGrid = new TreeGrid( {
dataSource: sampleData,
childMapping: 'subtasks',
treeColumnIndex: 1,
height: 400,
editSettings: {
allowAdding: true,
allowEditing: true,
allowDeleting: true,
mode: 'Cell',
newRowPosition: 'Below',
allowEditOnDblClick: false
},
load: load,
toolbar: ['Add', 'Delete', 'Update', 'Cancel'],
});
grid.appendTo('#Grid');
function load(): void {
var inst = this;
inst.element.addEventListener('mousedown', function (e) {
setTimeout(() => {
if (e.target.closest('.e-rowcell') ) {
if (inst.isEdit)
inst.endEdit();
let index = e.target.closest('.e-rowcell').parentElement.rowIndex;
inst.selectRow(index);
let cellindex = e.target.closest('.e-rowcell').getAttribute("aria-colindex");
let field = inst.columns[cellindex].field;
inst.editCell(index, field); // method to edit cell
}
}, 300);
})
} |
let grid: TreeGrid = new TreeGrid(
{
dataSource: sampleData,
childMapping: 'subtasks',
treeColumnIndex: 1,
height: 400,
editSettings: {
allowAdding: true,
allowEditing: true,
allowDeleting: true,
mode: 'Row',
newRowPosition: 'Below',
allowEditOnDblClick: false
},
load:load,
toolbar: ['Add', 'Delete', 'Update', 'Cancel'],
grid.appendTo('#Grid');
function load(): void {
var inst = this;
inst.element.addEventListener('mousedown', function (e) {
setTimeout(() => {
if (e.target.closest('.e-rowcell') ) {
if (inst.isEdit)
inst.endEdit();
let index = e.target.closest('.e-rowcell').parentElement.rowIndex;
inst.selectRow(index);
inst.startEdit(index) // method to edit cell
}
}, 300);
})
} |
let grid: TreeGrid = new TreeGrid(
{
dataSource: sampleData,
childMapping: 'subtasks',
treeColumnIndex: 1,
height: 400,
editSettings: {
allowAdding: true,
allowEditing: true,
allowDeleting: true,
mode: 'Row',
newRowPosition: 'Below',
allowEditOnDblClick: false
},
load: load,
toolbar: ['Add', 'Delete', 'Update', 'Cancel'],
columns: [
{
field: 'taskID', headerText: 'Task ID', isPrimaryKey: true, textAlign: 'Right',
validationRules: { required: true, number: true}, width: 90
},
{ field: 'taskName', headerText: 'Task Name', editType: 'stringedit', width: 220,edit: {
create: () => {
elem = document.createElement('input');
return elem;
},
read: () => {
return autoCompleteObj.value;
},
destroy: () => {
autoCompleteObj.destroy();
},
write: (args: { rowData: Object, column: Column }) => {
if((args.rowData as any).taskName == 'Plan timeline'){ //render based on conditions
autoCompleteObj = new AutoComplete({
dataSource: <{key: string, value: any}[]>grid.grid.dataSource,
fields: { value: 'taskName' },
value: args.rowData[args.column.field]
});
autoCompleteObj.appendTo(elem);
}else{
autoCompleteObj = new DropDownList({
dataSource: <{key: string, value: any}[]>grid.grid.dataSource,
fields: { value: 'taskName' },
value: args.rowData[args.column.field]
});
autoCompleteObj.appendTo(elem);
}
}
}
},
. . .
]
});
grid.appendTo('#Grid'); |
function load(): void {
var inst = this;
inst.element.addEventListener('mousedown', function (e) {
setTimeout(() => {
if (e.target.closest('.e-rowcell') ) {
if(e.target.closest('.e-rowcell').classList.contains('e-editedbatchcell')){
return;
}
if (inst.isEdit)
inst.endEdit();
let index = e.target.closest('.e-rowcell').parentElement.rowIndex;
inst.selectRow(index);
let cellindex = e.target.closest('.e-rowcell').getAttribute("aria-colindex");
let field = inst.columns[cellindex].field;
inst.editCell(index, field); // method to edit cell
}
}, 300);
})
} |
let grid: TreeGrid = new TreeGrid(
{
………..
columns: [
………………………………….
{ field: 'taskName', headerText: 'Task Name', editType: 'stringedit', width: 220,edit: {
create: () => {
elem = document.createElement('input');
return elem;
},
read: () => {
return autoCompleteObj.value;
},
destroy: () => {
autoCompleteObj.destroy();
},
write: (args: { rowData: Object, column: Column }) => {
…………………….
}else{
autoCompleteObj = new DropDownList({
dataSource: <{key: string, value: any}[]>grid.grid.dataSource,
…………………………………………………………….
change:function(args:any){
alert(args.value); // get the dropdown change value here.
}
});
autoCompleteObj.appendTo(elem);
}
}
}
},
……………………….
]
});
|