1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    36
    Vote Rating
    0
    flyingace is on a distinguished road

      0  

    Default Unanswered: Get record data into label?

    Unanswered: Get record data into label?


    Is there any way, apart from making extending Spinner or Label, to have the text in a spinner's label incorporate Record data the same way that an XTemplate can (ie, with curly braces)?

    Any help is always appreciated.

    Thanks,
    David

  2. #2
    Sencha User
    Join Date
    Mar 2012
    Location
    Germany, Dresden
    Posts
    35
    Answers
    3
    Vote Rating
    1
    mrVVoo is on a distinguished road

      0  

    Default


    Maybe you should take a look at DataViews. You can bind a record to them and describe with the dataMap attribute where to place this.

    something like this:
    dataMap: {
    label: {
    setLabel: 'place here the name of the value',
    }
    }

    take a look: http://docs.sencha.com/touch/2-0/#!/guide/dataview

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    36
    Vote Rating
    0
    flyingace is on a distinguished road

      0  

    Default


    I am returning to this some time after the fact, but I am hopeful that I will still be able to get a reply from one source or another.

    Mr. VVoo in his previous post suggested that I look into using DataViews. As it so happens, the path to the Spinner field in question originates in a DataView. This is to say that there is a DataView List which reveals a detail page and when one of the elements in the detail page is clicked a form comes up with the spinner in it.

    If I'm understanding the suggestion, for the spinner field I might use a DataView.component.DataItem, as this is the only class that I've been able to locate that uses a dataMap. But aren't DataItems intended to be used only as elements in a DataView? And the form that the spinner field is in is a Form panel.

    So am I misunderstanding the possible applications of DataItems, or should I still be looking for another way to get data from the record's data into my label?

  4. #4
    Sencha User
    Join Date
    Mar 2012
    Location
    Germany, Dresden
    Posts
    35
    Answers
    3
    Vote Rating
    1
    mrVVoo is on a distinguished road

      0  

    Default


    So at least my first answer was wrong. But there is an easier solution. You can put a listener on the field you want and listen on changing data (changing records) and then update the field.

    Code:
    {
      xtype: 'textfield',
      label: 'foo',
      listeners: {
        change: function(thisfield, newValue, oldValue){thisfield.setLabel(newValue);}, // listens on changing VALUE, after blur event
        updatedata: function(thisfield, newData){thisfield.setLabel(newData.someAttribute);}, //listens on data , for instance set by record
        keyup: ... //same as change but fires each time a key is released,
      }
    }

Thread Participants: 1