YUI datatable column count

204 views Asked by At

How do I get column count of a YUI datatable?

            var columns = dataTable.columns;
            var length = columns.length;

doesn't work.

I am using YUI2.

2

There are 2 answers

0
Fakrudeen On BEST ANSWER

In YUI2:

http://yui.github.io/yui2/docs/yui_2.9.0_full/docs/YAHOO.widget.DataTable.html

getColumnSet
YAHOO.widget.ColumnSet getColumnSet ( )
Returns the DataTable instance's ColumnSet instance.

 Returns: YAHOO.widget.ColumnSet
 ColumnSet instance.

like so:

var columnDefinitions = dataTable.getColumnSet().getDefinitions();
var length = columnDefinitions.length;
1
barnyr On

The Columns of a DataTable instance are held as an Attribute, not a property, so you'd need to use the following code:

dataTable.get("columns").length;