0

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.

Ivo Silva
  • 350
  • 4
  • 20

1 Answers1

2

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;
mschr
  • 8,531
  • 3
  • 21
  • 35
  • Great! That was really helpful, exactly what I meant with my question. Thank you! – Ivo Silva Aug 10 '12 at 11:25
  • @mschr can you please help me with this.. http://stackoverflow.com/questions/15826506/set-dojox-grid-datagrid-header-column-width-dynamically – Rachel Apr 05 '13 at 06:22