This is a migrated thread and some comments may be shown as answers.

Get column names with Javascript

3 Answers 796 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Ashley
Top achievements
Rank 1
Ashley asked on 18 Oct 2012, 08:49 PM
I'm having a hard time getting all of the column names for a tree list with javascript

I can call get_columns() and get an array of objects back, but they don't seem TreeListColumn objects - I can't call get_uniqueName() on them. I've dug around in the objects a bit in the debugger and I don't see the unique name in there at all.

Am I doing something wrong?

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 19 Oct 2012, 04:53 AM
Hi,

Try the following javascript to get the unique name.
JS:
function pageLoad() {
 var tree = $find("<%= RadTreeList1.ClientID %>");
 alert(tree.getColumnByUniqueName('ID').get_uniqueName());
}

Thanks,
Princy.
0
Ashley
Top achievements
Rank 1
answered on 19 Oct 2012, 12:58 PM
Hi Princy,

That's currently what I'm using, along with an array of all my column names. I need to do something on each column, but I also need to know it's column name.

What I'm asking is if there's a way to get all of the column names, not all of the columns. I know how to get a column by it's name, but I don't know how to get a column's name. I don't want to have to hard code an array of every column name.

The radgrid, for example, has this functionality:

grid.get_masterTableView().get_columns()[i].get_uniqueName()

But for the RadTreeList, the objects in get_columns() don't support the method get_uniqueName().

I'm actually quite disappointed that the Q3 release doesn't have any enhancements for the TreeList. It's very similar to the radgrid, but doesn't have nearly the functionality the radgrid does.
0
Princy
Top achievements
Rank 2
answered on 22 Oct 2012, 08:47 AM
Hi Ashley,

Try the following code snippet to achieve your scenario.

JS:
<script type="text/javascript">
    function pageLoad() {
        var tree = $find("<%= RadTreeList1.ClientID %>");
        for (var i = 0; i < tree.get_columns().length; i++) {
            alert(tree.get_columns()[i].get_uniqueName());
        }
    }
</script>

Hope this helps.

Regards,
Princy.
Tags
TreeList
Asked by
Ashley
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ashley
Top achievements
Rank 1
Share this question
or