PDA

View Full Version : Is it possible to use a template in the "treecolumn" of a treegrid?



jimeng
3 Jan 2012, 6:07 AM
We would like to turn the text in the tree-column into a link. I have seen examples in which a link is inserted in a column by setting "xtype" to "templatecolumn" and then providing the template and the values to insert into it. But in the case of the "tree-column", the "xtype" of the column is already "treecolumn". Is there a way to declare a column both a templatecolumn and a treecolumn? Or is there a way to nest a value rendered using a template as the text in a tree-column?

mitchellsimoens
3 Jan 2012, 6:14 AM
Have you looked at the treegrid example's source?

http://docs.sencha.com/ext-js/4-0/#!/example/tree/treegrid.html

I have moved this from Ext : Core to Ext : Q&A... this has nothing to do with the core.

jimeng
3 Jan 2012, 6:41 AM
Thanks, Mitchell, for moving this to the right place. I have looked at the treegrid example, but it does not use a template in the treecolumn. Is there another example that shows how to accomplish that?

mitchellsimoens
3 Jan 2012, 6:46 AM
Look at the 2nd column

jimeng
3 Jan 2012, 7:13 AM
Sorry. My question must not be clear. In that example, the first column has xtype of "treecolumn" and a note saying "this is so we know which column will show the tree". The second column has xtype of "templatecolumn" and a note saying "we must use the templateheader component so we can use a custom tpl". I understand that I could create a new column with xtype of "templatecolumn" and use a template to render the contents of that column as a link. My question is whether it is possible to use a template in the tree-column. Suppose we have a URL for each row and we want to render a link for all nodes, and we want that link to be in the column that also shows the hierarchical structure of the tree. Is there a way to do that?

jimeng
3 Jan 2012, 7:26 AM
After digging around in the API documentation a little more, I'm guessing that this might be possible by defining a custom component that extends whatever component has an alias of "treecolumn" and whatever component has an alias of "templatecolumn". Is that right?

jimeng
3 Jan 2012, 7:50 AM
Actually, I found the way to handle the specific example I used. If the node has properties of "href" and "hrefTarget" defined the tree-column will render the text as a link. That will satisfy my immediate need. Thanks.

da_b0uncer
10 Jul 2012, 6:58 AM
Is this possible with ExtJS 4.1?

I have an 'id' wich defines the tree (a/b/c) and a 'text' which should be shown (c). But the column config only permits 'dataIndex', which I have to point to 'id' or the tree doesn't work.

The 'text' config only changes the header of the column and the 'tpl' config doesn't seem to do anything.

I want my tree to look like

a

b
c

d


and not like

a

a/b
a/c

a/c/d



But it should still use a/c/d to pull the children from the server, when I click on d