How to change field on ejs-grid when event button clicked?

Can i use code like this? use [field]


<e-column [field]="nama" [customAttributes]="customAttributes" headerText="Asset Name"></e-column>

4 Replies 1 reply marked as answer

TS Thiyagu Subramani Syncfusion Team August 18, 2021 01:58 AM UTC

Hi Ihya, 

Thanks for contacting Syncfusion support. 

To achieve this requirement we suggest you to refresh the Grid columns using refreshColumns after changing the field name using button click. Please refer to the below code and sample link for more reference. 

 <e-column [field]='name' headerText='Order ID' width='120'></e-column> 

btnClick(args) { 
    (this as any).name = 'EmployeeID'; 
    this.grid.refreshColumns(); 
  } 



Please get back to us, if you need any further assistance. 

Regards, 
Thiyagu S 


Marked as answer

IF Ihya Fauzi replied to Thiyagu Subramani August 18, 2021 05:27 AM UTC

Thankyou very much, for the answer. Im using this method


<ng-template #template let-data>
            {{ data.asset_name }}
            {{ data.nama }}
          </ng-template>


IF Ihya Fauzi replied to Thiyagu Subramani August 18, 2021 05:32 AM UTC

Another Question, can you please watch the video? sorry for bad english


Attachment: 20210818_122928_e565549.zip


RS Rajapandiyan Settu Syncfusion Team August 19, 2021 01:15 PM UTC

Hi Ihya, 

Thanks for your update. 
 
Query: How to change field on ejs-grid when event button clicked? 

Kindly use the below code example to replace the column with another column. 


 
btnClick(args) { 
    if (this.grid.getColumnByField('CustomerName')) { 
      // get the column index 
      var index = this.grid.getColumnIndexByField('CustomerName'); 
      if (index > -1) { 
        //  replace the previous column with new column using its index position. 
        this.grid.columns[index] = { 
          field: 'ShipCity', 
          headerText: 'Ship City', 
          template: '<div>${ShipCity}</div>', 
          width: 150 
        }; 
        // refresh the Grid to affect the changes in UI 
        this.grid.refreshColumns(); 
      } 
    } 
} 
 




Query #2: Another Question, can you please watch the video? 

We are unable to reproduce the reported behavior (“search query is not send when perform paging action in the Grid”) at our end. Kindly share the below details to validate further. 

  1. Share the full Grid code file you have used.
  2. Which type data-binding you have used? Share the Adaptor details.
  3. How could you perform the searching operation in the Grid? share the code details.
  4. If possible share a simple issue reproducible sample.

Regards,  
Rajapandiyan S 


Loader.
Up arrow icon