Is there any way to set a dynamic name for column header, for example in a formatter function!?

I'll have a popup menu on the grid and depending on the chosen option it should change the name displayed in the column header.

有帮助吗?

解决方案

Its quite easy if you use dojo.query

var grid = dijit.byId('myGridId'),  NewHeader = "Foo Bar Text Content";
var columnHeaderNodes = dojo.query(
              '.dojoxGridHeader table th',
               grid.viewsHeaderNode)
var nthColumn = 12;
// if has child and its not a textnode - this may happen
// when there is a listener (dnd, click) attached for sorting etc.
if(columnHeaderNodes[nthColumn].firstChild && columnHeaderNodes[nthColumn].firstChild.nodeType != 3) 
    tgt = columnHeaderNodes[nthColumn].firstChild;
else tgt = columnHeaderNodes[nthColumn];
tgt.innerHTML = NewHeader;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top