View Full Version : How to get rid of hyperlinks in tree panel

24 Jun 2013, 6:13 AM
I have a tree panel that uses a store.
The service we call is providing an 'href' so in the model of the store I have an href field.
However when href is set, it automatically creates a hyperlink in the treepanel.
Is there a clean way to make it so that it doesn't make the treepanel have hyperlinks

24 Jun 2013, 8:00 AM
I found two ways of handling this: changing the tree column "cellTpl" config, or changing how you map the "href" property in your model. Both are straightforward.

If you want to change the "cellTpl" then take a look at the source for Ext.tree.Column (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.tree.Column). Yes, it's a private class but do it anyway. You'll see that it checks for the presence of the "href" property and creates an anchor tag or a span tag appropriately. Copy the existing "cellTpl", re-write it to always create a span instead of an anchor, and insert the new version in your grid's tree column config object.

If you want to change how the "href" property is mapped, use the "mapping" property of your "href" field definition. Change the "name" of the field to something else (like "recordHref" or whatever). If your store reader is Json, use "mapping: 'href'". If your reader is Array, instead of a string you would use the array index of the "href" property. Details can be found under Ext.data.Field#mapping (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Field-cfg-mapping).