Results 1 to 2 of 2

Thread: How to get rid of hyperlinks in tree panel

  1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    19
    Answers
    1
    Vote Rating
    0
      0  

    Default Answered: How to get rid of hyperlinks in tree panel

    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

  2. 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. 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.

  3. #2
    Sencha Premium Member
    Join Date
    Nov 2011
    Posts
    72
    Answers
    6
    Vote Rating
    13
      0  

    Default

    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. 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •