1. #1
    Sencha User
    Join Date
    Sep 2011
    Posts
    54
    Vote Rating
    0
    raju0574 is on a distinguished road

      0  

    Question Unanswered: how to display particular values from a store

    Unanswered: how to display particular values from a store


    hi all, i am getting the store values from this json
    JSON
    Code:
    {"data":[{"number":"24","question":"iPhone virtual keyboard can accommodate how many languages","option1":"21 languages","option2":"25 languages","option3":"19 languages","option4":"31 languages","answer": "21 languages"},{"number":"2","question":"How can you attach multiple pictures to an email","option1":"Not possible","option2":"Load them to the PC and send from there","option3":"Share button in Camera","option4":"Attach them one by one","answer": "Share button in Camera"}
    		]}
    Data Model and Store and Loading into store that json values
    Code:
    Ext.regModel('question1', {
        fields: ['number','question','option1','option2','option3','option4','answer'],
    });
    associatefinder.question1=new Ext.data.Store({
    model:"question1"
    });
    
    Ext.Ajax.request({
                    url: name,
                    success: function(response, request) {
    				data = Ext.decode(response.responseText);
    				var stores=Ext.getStore(associatefinder.question1);
    				stores.loadData(data.data);
                    }
                });
    by using ajax request am gettting and storing in my question store with two values in it,

    Now the problem is if i want to display only one value from that store,
    for that what i have to do

    code for displaying is
    Code:
    {
    		la
    	    xtype: 'dataview',
    		tpl: [			
    				'<table class=infoview>',
                    '<tpl for=".">',
    				'<tr><td class=infoview>1. {question}  ?</td></tr>',
    				'<tr><td class=right>{option1}</td></tr>',
    				'<tr><td class=right>{option2}</td></tr>',
    				'<tr><td class=right>{option3}</td></tr>',
    				'<tr><td class=right >{option4}</td></tr>',
    				'</tpl>',
    				'</table>',
                ],
    			styleHtmlContent: true,
                store: associatefinder.question1,
    			itemSelector: 'td.right',}}}
    Here i should get only one question..what i have to do for that.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,641
    Vote Rating
    434
    Answers
    3107
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    The '<tpl for=".">' means that it will iterate through all Array values.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

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

Tags for this Thread