Trying to disable "Actions column" when the settings are loaded dinamically
See original GitHub issueHi experts,
I’m trying to disable the actions column in the settings object when I populate it dinamically in the component’s constructor without success. Here is the code:
getSettings(): void {
let table_settings = {}
this._http.options(Config.API_SERVER_URL + '/inventario/producto/', this.user_session.token).subscribe(
(data) => {
let campos = data.actions.POST;
let col = {};
for (let key of Object.keys(campos)) {
if (campos[key].read_only == false) {
col[key] = { title: campos[key].label, }
}
}
table_settings['columns'] = col;
table_settings['actions'] = false;
table_settings['attr'] = { class: 'table table-striped table-bordered' }
this.table_settings = Object.assign({}, table_settings);
}
)
}
When I set the settings statically works!
@angular/* --> 4.0.0 ng2-smart-table --> 1.2.1
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Top Results From Across the Web
Dynamically disable jqgrid column - Stack Overflow
I want to disable few columns while editing but those columns will be enabled while adding through navGrid Add. I am using below...
Read more >Lightning:datatable dynamically disable rowactions
I want to dynamically enable/disable some rows based on an attribute on Custom_Object__c that is loaded into {!v.propertyMappings} . I tried ...
Read more >Disabling multiple columns of different IG's on page load
I believe what you want to do is disable the items. Enable, Disable DA actions apply to items not columns. The DA actions...
Read more >Filter Actions - Tableau Help
Select a source sheet or data source. If you select a data source or dashboard, you can select related sheets you want to...
Read more >Column Setup - Tabulator
In Tabulator columns are used to define how data loaded into your table ... not need a column for each field in your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, I see the problem, and have a hacky fix.
Basically what is happening is
TheadTitlesRowComponent.prototype.ngOnChanges
is not being triggered when the settings change. This function is what checks if the showActionColumn is true or not. You can see my little debugging text… It isn’t being called again whenNg2SmartTableComponent.prototype.ngOnChanges
is triggered from theng2settings = Object.assign({}, newSettings)
If the settings object you copy into had the action column hidden when the grid got initialized, the column stays hidden. Its just the default settings are what the ThreadTitlesRow component is stuck on.
So I just replaced
this.grid.setSettings
withthis.initGrid()
in theNg2SmartTableComponent.prototype.ngOnChanges
. This way, the grid object is replaced triggering theTheadTitlesTowComponent.prototype.ngOnChanges
. (Just like the Object.assign for the settings object in your app)I just ran into the same problem. Even when not changing settings, just copying the settings into a new object causes the Action column to appear with “Add New”.
this.ng2settings = Object.assign({}, this.tbl_settings);
I verified the settings hash before and after copying, the structure is correct and has the proper settings.