-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to change columns eg. you have 2 columns SSN and Name and then you have something like Title, Name, SSN and then you should have again only SSN and Name #570
Comments
I fixed this with changes to the ng-table.component.js A new conditional checks if any of the existing columns are no longer in the update values and removes them from the table. |
Thanks! You made my day :) |
I have opened a PR with this fix in it, but if this is like the ng2-charts repo it probably won't get merged. |
Also the change was made in ng2-table->components->table->ng-table.component.js. |
Hi, |
Hello, I'm a bit late but you can fork the repository and modify it then use your repository as source instead of the default one. For the column change bug, my solution is to rebuild all columns at every Set. So my columns are always the good ones and with the right order. You just have to be careful by refreshing your sorting configuration after setting new columns. Here is my column Set method: @Input()
public set columns(values:Array<any>) {
// Column reset added, now we always repopulate de columns instead of recycling, preventing columns refresh bugs
this._columns = [];
values.forEach((value:any) => {
if (value.filtering) {
this.showFilterRow = true;
}
if (value.className && value.className instanceof Array) {
value.className = value.className.join(' ');
}
this._columns.push(value);
});
} And here the component part with the configuration refresh: //Add LocalIT column for SHOW ALL mode
this.columns = [
{title: 'Local IT', name: 'LocalIT', filtering: {filterString: '', placeholder: 'LocalIT'}, sort:'', className: 'groupidColumnWidth'},
{title: 'Product Name', name: 'ProductName', filtering: {filterString: '', placeholder: 'Product Filter'}, sort:'', className: 'productColumnWidth'},
{title: 'Target', name: 'Target', filtering: {filterString: '', placeholder: 'GID Filter'}, sort: '', className: 'groupidColumnWidth'},
{title: 'Status', name: 'Status', filtering: {filterString: '', placeholder: 'Status Filter'}, sort: '', className: 'statusColumnWidth'},
{title: 'Creation Date', name: 'CreatedOn', sort: '', className: 'dateColumnWidth'},
{title: 'Modification Date', name: 'ModifiedOn', sort:'', className: 'dateColumnWidth'},
{title: 'Requestor', name: 'Requestor', filtering: {filterString: '', placeholder: 'GID Filter'}, sort:'', className: 'groupidColumnWidth'}
];
//Refresh the sorting onfiguration with the ne column and update de table with the new config
if(this.config){
this.config.sorting = {columns: this.columns};
}
this.onChangeTable(this.config); I hope it can help someone, Have a nice day |
@itsnotme01 your solution worked for me. I changed the set values in ng2-table->components->table->ng-table.component.js. |
We've used ng2-table and bring rows and column(names) from server. The columns (Names, Count and Order can change). How to change columns eg. you have 2 columns SSN and Name and then you have something like Title, Name and SSN in this order and then you should have again only SSN and Name.
In first change:
SSN and Name => Title, Name and SSN
there is not seen columns as expected, but SSN, Name and Title.
In second change :
Title, Name and SSN (seen SSN, Name and Title) => SSN and Name
there is not seen columns as expected, but SSN, Name and Title (and all the values in column Title are 'undefined' (yes, we don't bring value for Title, because we don't expect there is column for Title).
There is our code. What else should we do?
The text was updated successfully, but these errors were encountered: