|
app.component.html:
<input class="form-control"
type="text" name="userQuestion" id="userQuestions">
<button (click)="AddColumns()">Add columns</button>
<ejs-grid #grid [dataSource]='data' [enablePersistence]='false' allowPaging='true' [pageSettings]='pageOptions'
allowSorting='true'>
<e-columns>
……………….
……………….
</e-columns>
</ejs-grid>
app.component.ts:
AddColumns() {
var colName = (document.getElementsByClassName("form-control")[0] as any)
.value;
var obj = { field: colName, headerText: colName };
this.grid.columns.push(obj as any); //you can add the columns by using the Grid columns method
this.grid.refreshColumns();
} |
Hi Vignesh Sivagnanam,
I am trying to find the angular methods to remove columns but the online documentation does not seem to reference them. Please note I do not mean hide but if the local storage has a column which no longer exists I want to remove it.
Also your stackblitz example does seem to work.
Hi Jason,
Thanks for your update
We have checked your shared information; we could see that you are like to add/remove the column dynamically after the Grid initialization. Once the Grid is rendered with initial settings when the EnablePersistence is true, we can add the column to the Grid by using only the Grid inbuilt methods. To reflect our changes in the Grid, first we need to notify the Grid model. To notify the Grid model and reflect our changes properly in Grid, we can use only our Grid inbuilt methods. This was the default behavior of our Grid.
Regards,
Rajapandi R
This is still an issue for us.
Are you planning on being able to enable persistency and also include new columns.
Otherwise what you are saying is, we cannot have persistency on unless column never change - which is not a great for us.
Or are you saying, this is a how the grid works, you are not going to change it, and we need to work around the issue, thanks.
Really, if you have a feature like persistency it should handle new columns being added even when they are not in the object stored in local storage.
This is a problem that affects our clients. When I set up some columns and turn on persistence, everything works as expected. However, there is no way to add a new column in a new application version and make it visible to the client without erasing the entire saved value. This is a serious limitation
Hi Customers,
When the enablePersistence property is set to true in the Syncfusion Grid component, column configurations are persisted. If you need to add new columns to the existing persisted state, you can achieve this by using the Grid’s built-in methods like column.push, and then call the refreshColumns method to update the UI with the new columns. This is the default behavior based on our current architecture. We have already discussed about your requirement in our documentation which can be accessed from the below link,
Documenation: https://ej2.syncfusion.com/angular/documentation/grid/state-management#add-a-new-column-in-persisted-columns-list
Regards,
Rajapandi R