Enable or Disable Column in Edit Dialog not working

Hi support,

I'm using the TreeGrid Element to edit my data.

I want to reduce the columns in the grid, but still want to edit them.

So I'm using editSettings mode: Dialog which is working.

But I can't display the additional fields in the dialog.

With normal grids the code works perfectly, but not with treegrid.

Here is my code:

function actionBegin(args) {
console.log(args);
if ((args.requestType === 'beginEdit' || args.requestType === 'add')) {
for (var i = 0; i < this.columns.length; i++) {
console.log(this.columns[i].field);
if (this.columns[i].field == "classcolumnid") {this.columns[i].visible = true;}
if (this.columns[i].field == "classcolumnitems") {this.columns[i].visible = true;}
if (this.columns[i].field == "classcolumnsort") {this.columns[i].visible = true;}
if (this.columns[i].field == "classcolumnactive") {this.columns[i].visible = true;}
}
}
if ((args.requestType === 'save') || (args.requestType === 'cancel')) {
for (var i = 0; i < this.columns.length; i++) {
if (this.columns[i].field == "classcolumnid") {this.columns[i].visible = false;}
if (this.columns[i].field == "classcolumnitems") {this.columns[i].visible = false;}
if (this.columns[i].field == "classcolumnsort") {this.columns[i].visible = false;}
if (this.columns[i].field == "classcolumnactive") {this.columns[i].visible = false;}
}
}
}

What can I do?

Regards,

Stephan


3 Replies 1 reply marked as answer

SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team November 27, 2023 02:53 PM UTC

Hi Stephen,


Greetings from Syncfusion support.


We can replicate the issue from our end using the code snippet you have provided. We suggest you to use the columns from grid instead of treegrid Instance to show or hide the columns on dialog editing. Please refer to the following code snippet.


actionBegin: (args=> {

    if (args.requestType === 'beginEdit' || args.requestType === 'add') {

        for (var i = 0i < treeGridObj.grid.columns.lengthi++) {

          if (treeGridObj.grid.columns[i].field == 'Progress') {

            treeGridObj.grid.columns[i].visible = true;

          }

        }

      }

      if (args.requestType === 'save' || args.requestType === 'cancel') {

        for (var i = 0i < treeGridObj.columns.lengthi++) {

          if (treeGridObj.grid.columns[i].field == 'Progress') {

            treeGridObj.grid.columns[i].visible = false;

          }

        }

      }

  },

 


Sample : https://stackblitz.com/edit/ejumru-zd6cdg?file=index.js


Please get back to us if you need further assistance.


Regards,

Shek


Marked as answer

SS Stephan Schrade November 27, 2023 03:11 PM UTC

Hi support,

this works now very well.

Many thanks.

Perhaps you can add this to the "How to" - Section of the TreeGrid documentation.

Regards,

Stephan



SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team November 29, 2023 02:35 PM UTC

Hi Steplen,


Thanks for your valuable feedback. We have taken into consideration, and we will include the documentation for future reference.


Thanks and regards,

Shek


Loader.
Up arrow icon