Results 1 to 5 of 5

Thread: How to use tpl with displafield in Ext JS 4.2

  1. #1

    Default Answered: How to use tpl with displafield in Ext JS 4.2

    Hi,

    I want to use a displayfield to show attachments as links via tpl setting, but don't know how.


    This is the fields section of my model, the 'attachments' field would be an array:
    Code:
        fields: [
            ...
            { name: 'attachments', type: 'auto' }
        ]


    and this is the displayfield configration I've been using to test tpl, but I get nothing displayed:
    Code:
    {
        name: 'attachments',
        fieldLabel: 'Attachments',
        tpl: new Ext.XTemplate(
            '<tpl foreach=".">',
                '<p>id: {id}</p>',
            '</tpl>'
        )
    }

    and this is one of the 'attachments' field data
    Untitled.png

    Thanks for your help, any suggestion will be welcome and appreciated.

  2. This would require a custom extension to handle an object, the value of the display field is only meant to accept a simple value (string/number)

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    This would require a custom extension to handle an object, the value of the display field is only meant to accept a simple value (string/number)
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  4. #3

    Default

    Quote Originally Posted by mitchellsimoens View Post
    This would require a custom extension to handle an object, the value of the display field is only meant to accept a simple value (string/number)
    This clarifys how the issue come.

    What makes me confused is that the 'tpl' configuration is supposed to deal with objects but it can only handler string/number here.

    Anyway, I think there's an alternative way to achieve my goal. Using a converted field to convert attachment array to string and then display them with renderer.

    I still would like to get some hint from you that how to create such a custom extension to handler this object field, thanks!

  5. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    The tpl is not used for the value
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  6. #5

    Default

    Quote Originally Posted by mitchellsimoens View Post
    The tpl is not used for the value
    Ok, now I see, thank you.

Tags for this Thread

Posting Permissions

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