Reputation: 471
I am using slickgrid in an angular application which supports multiple languages. How can I update the column headers when the selected language is changed. My column definition looks like this and what I basically want is the grid to call myI18N again to update the column title.
{ id: "myid", name: myI18nFn('idKey'), field: "myid", width: 100}
I have an angular event that detects changes and I have access to the grid object there, I am just not sure on what I need to do make it update the column header
Upvotes: 2
Views: 2745
Reputation: 19
You can also use the next slickgrid method for it:
grid.updateColumnHeader(
columnId: number | string,
title?: string | HTMLElement | DocumentFragment,
toolTip?: string
)
In your case it will look like grid.updateColumnHeader("myid", myI18nFn('idKey'))
.
Upvotes: 0
Reputation: 3276
You need to update colDef.name
property when the language changes and then trigger the grid to rebuild the header row (which occurs in the createColumnHeaders
method in the SlickGrid source). The easiest way is to just update the column list with a setColumns
call, which triggers a rerender of the entire grid:
function updateColumnHeaders()
{
var cols = grid.getColumns();
for(var i = 0, il = cols.length; i < il; i++)
{
cols[i].name = myI18nFn(cols[i].id);
}
grid.setColumns(cols);
}
Upvotes: 2