views:

358

answers:

3

I would like to be able to edit the column headers in the same manner that I can alter row-values. Anyone come up with a way to do this? I don't see any mention of it in the docs.

A: 

The column header are set up in the columnDefs:

 var myColumnDefs = [
      {key:"myID", label:"id", sortable:true},
      {key:"myDate", label:"date", sortable:true},
      {key:"MyStatus", label:"status", sortable:false}
                    ];

if you want to be able to change it dynamically, you will have to remove the label's value, and apply css to the first row, so it looks like it is a header. and then use inline Cell Editing as usual in YUI. Just an idea! 'Cause so far I don't think YUI is providing method to just do that!

Tom
A: 

I wanted to place a checkbox in the header instead of a regular title. The label attribute will take HTML.

Here is an example of the myColumnDefs I pass into the YUI Datatable:

var myColumnDefs = [
    {key:"check", label:'<input id="check-all" type="checkbox" onclick="checkAll()">', formatter:"checkbox"},
    {other columns}
];            
Justin Tanner
A: 

http://yuilibrary.com/projects/yui2/ticket/2528327

Looks like its going to be there eventually, but Luke Smith posted a POC that works for me. Nice!

Jim Simpson