I add column to columns with defaultValue option but it's not work and i try to add new property to the dataSource but it still not work.
https://stackblitz.com/edit/angular-mqa5hw-kwufzb?file=app.component.ts
I need help! Someone can help me?
Hi Quang,
We have checked your reported problem and if you use refreshColumns method, it will update the changes that has been made into the TreeGrid columns. In order to refresh the TreeGrid, we suggest to use Refresh method of the TreeGrid.
Refer to the code below:-
|
App.Component.ts:-
clicked(): void { let columnName = { field: 'newCol', width: 100, defaultValue: 'Default' }; this.data.map((d) => Object.assign(d, { newCol: 'Default' })); this.treegrid.columns.splice(2, 0, columnName); //Add the columns this.treegrid.refreshColumns(); this.treegrid.refresh(); } |
Modified sample link:- https://stackblitz.com/edit/angular-mqa5hw-suasbi?file=app.component.ts
Refer to the documentation link:-
https://ej2.syncfusion.com/angular/documentation/api/treegrid/#refresh
Please get back to us if you need any further assistance.
Regards,
Farveen sulthana T
Note:- If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Hi Farveen Sulthana Thameeztheen Basha,
Thanks for your support. It's work ok but if i using type/edit type dropdownlist. After refresh treegrid in dropdownlist column still not display default value(i setup first item value of dropdownlist is defaultValue of column). And one more thing if i select an value in dropdownlist and save it, i edit this column again dropdownlist will reset value of this cell.
I need help for this problem! Someone can help
Hi Ayush,
Thanks for the update.
Query: After refresh treegrid in dropdownlist column still not display default value(i setup first item value of dropdownlist is defaultValue of column). And one more thing if i select an value in dropdownlist and save it, i edit this column again dropdownlist will reset value of this cell.
Based on your query, we understand you need to show the default value after refreshing the treegrid or after editing the cell value. By default, the defaultValue property is used only when adding a new record to the TreeGrid.
Please refer to the below API documentation,
https://ej2.syncfusion.com/documentation/api/treegrid/column/#defaultvalue
If you want to show the default value while editing or after refreshing the treegrid, we suggest you use the actionBegin event. In the actionBegin event with args.requestType as beginEdit you can change the value before editing.
Please refer to the below code example,
|
<ejs-treegrid #treegrid [dataSource]="data" height="400" childMapping="subtasks" [treeColumnIndex]="1" [selectionSettings]="selectionsettings" (checkboxChange)="checkboxChange($event)" (actionBegin)="actionBegin($event)" [editSettings]="editSettings" [toolbar]="toolbar" >
….
actionBegin(args) { console.log(args, 'actionBegin event triggered');
if (args.requestType == 'beginEdit') { args.rowData.newCol = 'Default'; // here you can define the default value } }
|
Please refer to the below sample,
https://stackblitz.com/edit/angular-mqa5hw-mlqyoh?file=app.component.ts,app.component.html
Still, if you are facing the issue, kindly share the below details
Please get back to us if you need more assistance.
Regards,
Pon selva
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Thank for your support!
Now it's working but it has new problem when i use virtualization.
After add newCol i click to cell of newCol to edit data but new error like below is appear and dropdown is empty options.
You can check the link for detail: https://stackblitz.com/edit/angular-mqa5hw-pvg1sz?file=app.component.html
Hi Quang,
Thanks for the update.
Query: it has new problem when i use virtualization..
We have discussed same issue in this forum. Please follow up the below forum for further information on the dropdown edit with virtualization.
https://www.syncfusion.com/forums/176954/can-not-load-dropdownlist-edit-when-enable-virtualization
Please get back to us if you need more assistance.
Regards,
Pon selva
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.