PDA

View Full Version : Panel and tpl with store?



vivendi
14 Feb 2012, 8:31 AM
I have a panel in Designer 2 which i need to fill with some columns/rows, just like a html table.

I see that the Panel has the 'tpl' attribute, but i don't see how i can add a store to it. My store has JSON data, and i want to display this data as html inside that panel.

How can i do this..?? What would be a good way??

aconran
14 Feb 2012, 12:43 PM
There are a couple of different solutions for what you are looking for.

If you already have the data in a Store then the one that you probably want is to put an Ext.view.View into your Panel and use a layout of fit. This will stretch the view to 100% width and height of the panel it is in.

Bind the View to the store of your choosing. Then configure a tpl for the View. Every record will be passed in a loop to the template in a tpl for="." loop.

vivendi
15 Feb 2012, 5:18 AM
I couldn't find the Ext.view.View, but i did find Ext.dataview.DataView. I guess that's the one you mean. I can tell it what store to load and i can change its 'tpl' property. So its working for me. Thanks.

vivendi
15 Feb 2012, 6:25 AM
Guess it didn't work after all :(

I added the store to the dataview and added the following in the itemTpl property:



<tpl for=".">
<div style="width:100px; height:80px; background:#CCC;">
{Name}
</div>
</tpl>


All this gives me is the first item of the JSON data. I also tried it without the <for> loop, but that didn't help either.

Any idea what the problem could be? Perhaps a bug?

bharatn
15 Feb 2012, 8:07 AM
Make sure you have store configured correctly (See Store/Proxy/Reader docs).
Check the record count after data load.

vivendi
16 Feb 2012, 4:48 AM
Make sure you have store configured correctly (See Store/Proxy/Reader docs).
Check the record count after data load.
Hmm, you're right, it does say that only one record is loaded, eventhough i get alot of JSON data. I'll check to make sure if my JSON data is properly formatted.

Edit:
Thanks, i found that i had the idProperty wrong.