board logo
Posted by: WUICTeam - Friday, November 6, 2026 9:02:03 AM
[b]Question[/b] I add a per-row button to a [c]<wuic-list-grid>[/c] from my component: in [c]ngOnInit[/c] I push a column with [c]mc_ui_column_type: 'button'[/c] into [c]columnMetadata[/c] and put my code, as a string, in the callback field. The button is rendered but it is greyed out and clicking does nothing. The same string works when the column is defined in the database. What is different? [b]Answer[/b] In code you must set the [b]function[/b] [c]mc_button_action__fn[/c], not the callback string. The string ([c]mc_button_action[/c]) is compiled into [c]mc_button_action__fn[/c] by the metadata provider only while the metadata is being loaded from the server. A column you push afterwards, from a [c]fetchInfo$[/c] subscription, is never compiled. The row button checks [c]mc_button_action__fn[/c] to decide whether it is enabled, so without it the button stays disabled. The callback receives [c](datasource, record, event, field, wtoolbox)[/c]. Note that [c]record[/c] is a map of [c]BehaviorSubject[/c], so read values with [c].value[/c]. Also set [c]mc_button_caption[/c], otherwise the label falls back to the column name. [code] ngOnInit() { this.ds.fetchInfo$.subscribe(info => { if (!info?.metaInfo) return; const cols = info.metaInfo.columnMetadata; // fetchInfo$ is a BehaviorSubject and re-emits: keep it idempotent if (cols.some(c => c.mc_nome_colonna === 'rinnova_action')) return; cols.push({ mc_nome_colonna: 'rinnova_action', mc_ui_column_type: 'button', mc_button_caption: 'Rinnova', mc_button_image: 'pi pi-refresh', mc_button_action__fn: (datasource: any, record: any, event: any, field: any, wtoolbox: any) => { const id = record['CustomerTransactionID']?.value; // ... call your endpoint with id ... datasource.fetchData(); // refresh the grid (not refresh()) }, } as any); }); } [/code] [b]Mistake to avoid[/b] Do not mix the two paths: database metadata = callback string, in-code = function. Also remember that the toolbar (table) actions live in a different array, so a row button never goes there. [url=https://wuic-framework.com/docs/custom-actions]Documentation: Custom Actions[/url]