We tried with checkbox in ejs contextmenu, its working, but what we need is check box should function in treegrid contextmenu (ejs-treegrid). Can you please suggest us how can we handle this?
Alright, let me explain in brief about the requirement, you can in the above that Filter - On/off, yes its working fine in contextmenu, but what we needs is that to be changed to enable Off and On in Check Box (Checked is On/Uncheck is off. We are using treegrid template. We tried with,
UI components can also be placed inside the each li element of ContextMenu.
In the following example, CheckBox component is placed inside each li element and this can be achieved by creating CheckBox component in beforeItemRender event and appending it into the li element.
<ejs-contextmenu id='contextmenu' [target]='target' [items]= 'menuItems' (beforeItemRender)='itemRender($event)' (beforeClose)='beforeClose($event)'></ejs-contextmenu>`Where we are struck is, how can we get <ejs-contextmenu> into..
<ejs-treegrid>
or how can we handle checkbox contextmenu in treegrid template.
Hope this clears your doubt, if not kindly revert me back.
Thanks and regards,
Chris Johnson
|
App.Component.html
<ejs-treegrid #treegrid
[dataSource]="data"
childMapping="subtasks"
height="350"
allowPaging="true"
[pageSettings]="pageSettings"
allowSorting="true"
[treeColumnIndex]="1">
<e-columns>
<e-column field="taskID"
headerText="Task ID"
width="100"
textAlign="Right"></e-column>
</e-columns>
. . .
</ejs-treegrid>
<ejs-contextmenu id="contextmenu" target=".e-gridheader" [items]="menuItems"
(beforeItemRender)="itemRender($event)" (beforeClose)="beforeClose($event)"></ejs-contextmenu>
App.Component.ts
public beforeClose(args: BeforeOpenCloseMenuEventArgs) {
if ((args.event.target as Element).closest('.e-menu-item')) {
args.cancel = true;
. . .
let frame: HTMLElement = checkbox.querySelector('.e-frame');
if (checkbox && frame.classList.contains('e-check')) {
frame.classList.remove('e-check'); // do your actions when uncheck the checkbox
this.treegrid.allowFiltering = false;
} else if (checkbox) {
frame.classList.add('e-check');
this.treegrid.allowFiltering = true; // do your actions when check the checkbox
}
}
}
public itemRender(args: MenuEventArgs) {
let check: Element = createCheckBox(createElement, false, {
label: args.item.text,
checked: false,
});
args.element.innerHTML = '';
args.element.appendChild(check);
}
}
|