PDA

View Full Version : List itemTpl will bind but won't display content



baushaug
28 Feb 2012, 1:55 PM
This is a hack that is related to another post ( http://www.sencha.com/forum/showthread.php?183998-Problem-with-quot-Load-Data-quot-for-JSon-Store-from-.NET-web-service.&p=744172#post744172 ).

Basically, I can't get the "Load Data" to work in the Designer 2 so I've improvised by directly invoking the AJAX proxy's request method in a Controller action and bind the response string via the "setter" method on the list's "store" configuraiton like so:


//get all stores Ext.Ajax.request({
url: 'http://mobilenew.brookshirebrothers.com/BBMobile.asmx/GetAllStores',
method: 'post',
headers: { 'Content-Type': 'application/json;charset=utf-8' },
success: function (response, options) {
allbbstores = eval("(" + response.responseText + ")");
Ext.getCmp('storeinfolist').setStore(allbbstores.d);
Ext.getCmp('storefeedback').setValue(response.responseText);

},

failure: function (response, options) {
Ext.getCmp('storefeedback').setValue(response.responseText);
}
});


I successfully get a JSON return string from my web service method that looks like:


{"d":[ {"STORENUMBER":1,"STORE":"Lufkin,Texas 75901--301 South Chestnut--Fresh Harvest Food & Pharmacy-- Store#1"},
{"STORENUMBER":2,"STORE":"Nacogdoches,Texas 75961--1216 South Street--Brookshire Brothers Food & Pharmacy-- Store#2"},
{"STORENUMBER":4,"STORE":"Timpson,Texas 75975--839 North First Street--B & B Food-- Store#4"},
{"STORENUMBER":5,"STORE":"Lufkin,Texas 75901--816 North Timberland Drive--Brookshire Brothers Food & Pharmacy-- Store#5"}



I have an itemTpl config that looks like:
<div>{STORENUMBER} {STORE}</div>

The result is, my list does bind to the returned data set but each item is blank. I would like for the "STORE" JSON value to appear as text for the item in the list.

My question is how do I do this ? Am I missing some certain configuration ? I've followed the example in the docs, which I couldn't get to do as much as my application's List does.

I'm under some serious pressure to produce a mobile app for my employer, so any help would be greatly appreciated.

aconran
28 Feb 2012, 2:06 PM
I'd suggest getting the store working and going about things the correct way.

baushaug
28 Feb 2012, 2:23 PM
I agree with you Aaron, although if the API is stable, I'm not understanding why this is happening and not working.

I was forced to go this route because I couldn't reference my stores or views by the suggested use of "getter" methods as explained in this article: http://www.sencha.com/learn/architecting-your-app-in-ext-js-4-part-3 I understand this article was referring to Ext JS MVC but I also read in the sparse Touch documentation and forums that Touch is supposed to work the same way. Although when I tried to reference a view or store the "getter" failed me, so like any desperate, pressured developer I had to find a work around.

Again, I'm under the gun here so any help from any gurus would help right now.

aconran
28 Feb 2012, 2:29 PM
They don't work because the code is in an init method instead of the launch method.

This was a change that was made in between the betas and the designer has not changed yet.

baushaug
28 Feb 2012, 2:49 PM
Ok, now I'm learning something. Until, I can get the network and permissions issues handled all I can do is continue to hack.

Thanks for the response.