Pre-Select Checkbox in Tree Table based on JSON data
suryakanta101 opened this issue · 2 comments
suryakanta101 commented
Hello @mazdik
Can it be possible to Pre-Select Checkbox based on JSON received from service on DataTable.
ex: [
{
"id": "1",
"name": "ASMODIANS",
"isSelected" : true,
"data": {
*****
Something like below might possible by adding a new attribute to data transformer
[transformer = (node: TreeNode, level: number) => {
const data = {
expandable: true,
$$level: level,
$$checked: node.isSelected,
hasChildren: (node.children && node.children.length > 0)
};
How to add "$$checked" here to selection object ???
mazdik commented
this.dataTable.rows = this.prepareTreeData(data);
this.dataTable.rows.forEach((x: Row) => {
if (x.$$checked) {
this.dataTable.selectRow(x.$$index);
}
});
suryakanta101 commented
this.dataTable.rows = this.prepareTreeData(data); this.dataTable.rows.forEach((x: Row) => { if (x.$$checked) { this.dataTable.selectRow(x.$$index); } });
Thanks, its working :)