1. #1
    Sencha User
    Join Date
    Oct 2012
    Location
    Toulouse
    Posts
    58
    Answers
    7
    Vote Rating
    0
    novadys-sbu is on a distinguished road

      0  

    Default Answered: Getting a value in store with a variable

    Answered: Getting a value in store with a variable


    Hello everyone,

    Sorry my title isn't very clear. My problem is that I have dynamic models and store that I create into a string in PHP and the then 'eval' once the success is triggered from the AJAX request.
    In my PHP string, I need to do is something like this :

    Code:
    var fields = store$strUniqueId.getModel().getFields();
    var myItem = store$strUniqueId.getAt(i); 
    for(var j=0; j < fields.length; j++){         
    var myCurrentField = fields.getAt(j);
    var myCurrentFieldName = myCurrentField._name;
    var myCurrentFieldValue = myItem.data.myCurrentFieldName;                                                     
    $strGrid .= "console.debug(myItem.data.myCurrentFieldName);
    strHTML = strHTML + myCurrentField._name + ' : ' + myCurrentFieldValue + '<br />'; 
    ;
    with myCurrentFieldName being a variable. Does anyone have any ideas ?

    I can only seem to access the value of a specific field of a record using the actual name of the field. But I do not know it because my models are dynamic.

    Thanks guys

    Sarah
    Sarah Burrell
    R & D Developer at Novadys International

  2. Code:
                                $myContentHTML .= "<b>".$alias."</b> : ' + myItem.data.".addslashes(utf8_encode($myProperty->Name))." + '<br />' + '";
    I ended up doing this in a php servlet

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,217
    Answers
    3519
    Vote Rating
    859
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    So how do you know what field to use?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Oct 2012
    Location
    Toulouse
    Posts
    58
    Answers
    7
    Vote Rating
    0
    novadys-sbu is on a distinguished road

      0  

    Default I don't know

    I don't know


    I want to iterate through them and render them as a "key : value" format
    Any ideas ?
    Sarah Burrell
    R & D Developer at Novadys International

  5. #4
    Sencha User
    Join Date
    Oct 2012
    Location
    Toulouse
    Posts
    58
    Answers
    7
    Vote Rating
    0
    novadys-sbu is on a distinguished road

      0  

    Default So...

    So...


    I'm assuming this isn't possible and I'll have to find a work around
    Sarah Burrell
    R & D Developer at Novadys International

  6. #5
    Sencha User
    Join Date
    Oct 2012
    Location
    Toulouse
    Posts
    58
    Answers
    7
    Vote Rating
    0
    novadys-sbu is on a distinguished road

      0  

    Default Still stuck

    Still stuck


    Code:
                                $myContentHTML .= "<b>".$alias."</b> : ' + myItem.data.".addslashes(utf8_encode($myProperty->Name))." + '<br />' + '";
    I ended up doing this in a php servlet
    Sarah Burrell
    R & D Developer at Novadys International

Thread Participants: 1