1. #1
    Sencha User
    Join Date
    Jun 2009
    Posts
    58
    Vote Rating
    0
    vivendi is on a distinguished road

      0  

    Default Panel and tpl with store?

    Panel and tpl with store?


    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??

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,269
    Vote Rating
    122
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    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.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha User
    Join Date
    Jun 2009
    Posts
    58
    Vote Rating
    0
    vivendi is on a distinguished road

      0  

    Default


    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.

  4. #4
    Sencha User
    Join Date
    Jun 2009
    Posts
    58
    Vote Rating
    0
    vivendi is on a distinguished road

      0  

    Default


    Guess it didn't work after all

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

    Code:
    <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?

  5. #5
    Sencha User
    Join Date
    Jun 2011
    Posts
    350
    Vote Rating
    1
    bharatn is on a distinguished road

      0  

    Default


    Make sure you have store configured correctly (See Store/Proxy/Reader docs).
    Check the record count after data load.
    Bharat Nagwani
    Sencha Designer Development Team

  6. #6
    Sencha User
    Join Date
    Jun 2009
    Posts
    58
    Vote Rating
    0
    vivendi is on a distinguished road

      0  

    Default


    Quote Originally Posted by bharatn View Post
    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.

Thread Participants: 2