user256717
user256717

Reputation:

YUI datatable column count

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.

Upvotes: 0

Views: 203

Answers (2)

user256717
user256717

Reputation:

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;

Upvotes: 0

barnyr
barnyr

Reputation: 5678

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;

Upvotes: 3

Related Questions