1. #1
    Sencha User
    Join Date
    May 2012
    Location
    Bangalore
    Posts
    95
    Vote Rating
    1
    Rameshlamani is on a distinguished road

      0  

    Default How to parse JSON and bind to tpl in sencha touch2

    How to parse JSON and bind to tpl in sencha touch2


    Hi, i am new to sencha touch2. i am consuming the web service it is populating JSON data as below. I need to bind short description data to my Xtemplate tpl tag. but i am not able to see short description in tpl. Please any one can help me how to bind and display data.

    Code is here:

    Code:
    Ext.define("GS.view.Twitter", {
        extend: 'Ext.navigation.View',
        xtype: 'twitter',
        config: {
            title: 'Twitter',
            iconCls: 'star',
            items: {
                xtype: 'panel',
                itemTpl: '{title}',
                title: 'Recent Posts',
                store: {
                    autoLoad: true,
                    //params:{categoryId: 1},
                    fields: ['ShortDescription'],
                    proxy: {
                        type: 'jsonp',                  
                        url: 'http://MyURL link', 
                        reader: {
                            type: 'json',                     
                            root: 'd'                       
                        }
                    }
                },
                itemTpl: '<p class="temp_low">{ShortDescription}</p>'            
            }
        }
    });
    JSON output is here:

    Code:
    { "d" : { "CategoryId" : 0,
          "CategoryName" : "Apartment",
          "CreatedBy" : null,
          "FloorPlanImages" : [ { "CategoryId" : 0,                    
                "ImageName" : "Roya.jpg",
                "ImageUrl" : "c://imagefolder",
                "ModifiedBy" : null,
                "ProjectId" : 0,
                "SortOrder" : 1,
                "StatusGalleryId" : 0,
                "__type" : "ImageGallery:#Entities"
              },
              { "CategoryId" : 0,                   
                "ImageName" : "slide-2.jpg",
                "ImageUrl" : "www/Images/slide-1.jpg",
                "ModifiedBy" : null,
                "ProjectId" : 0,
                "SortOrder" : 1,
                "StatusGalleryId" : 0,
                "__type" : "ImageGallery:#Entities"
              }
            ],
          "GalleryImages" : [ { "CategoryId" : 0,                   
                "ImageName" : "gallery.jpg",
                "ImageUrl" : "Images/slide-3.jpg",
                "ModifiedBy" : null,
                "ProjectId" : 0,
                "SortOrder" : 1,
                "StatusGalleryId" : 0,
                "__type" : "ImageGallery:#Entities"
              } ],
          "ImageUrl" : "Images/slide-2.jpg",
          "LongDescription" : " apartment",
          "ModifiedBy" : null,
          "PromoUrl" : "Images/Play-Normal-icon.png",
          "ShortDescription" : "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical  dolorem eum fugiat quo voluptas nulla pariatur\"",
          "__type" : "Category:#Entities"
        } }

  2. #2
    Sencha User
    Join Date
    Apr 2012
    Posts
    103
    Vote Rating
    10
    pepperseb is on a distinguished road

      0  

    Default


    You're using twice itemTpl.

  3. #3
    Sencha User
    Join Date
    May 2012
    Location
    Bangalore
    Posts
    95
    Vote Rating
    1
    Rameshlamani is on a distinguished road

      0  

    Default


    i have removed itemTpl: '{title}'.now also it is not working

  4. #4
    Sencha User
    Join Date
    Apr 2012
    Posts
    103
    Vote Rating
    10
    pepperseb is on a distinguished road

      0  

    Default


    Because you're using a panel and not a dataview, you must use tpl instead of itemTpl.

    If you want to display more information (latest tweets), you should use a list (dataview)

  5. #5
    Sencha User
    Join Date
    May 2012
    Location
    Bangalore
    Posts
    95
    Vote Rating
    1
    Rameshlamani is on a distinguished road

      0  

    Default


    Hi, as per you i have changed itemTpl to tpl and xtype: 'list' to xtype: 'dataview' written but data is not displaying in screen please can check my code what is d pbm...

  6. #6
    Sencha User
    Join Date
    May 2012
    Location
    Pune,India
    Posts
    23
    Vote Rating
    -1
    kalim.sayyad is an unknown quantity at this point

      0  

    Default


    Hey,I had the same problem,but its not too difficult.Just try my code.Remember to give the proper path of sdk folder in index.html

    http://dl.dropbox.com/u/65876949/Shop.zip

  7. #7
    Sencha User
    Join Date
    May 2012
    Location
    Bangalore
    Posts
    95
    Vote Rating
    1
    Rameshlamani is on a distinguished road

      0  

    Default


    thanq so much. i will try your solution and let u know.

  8. #8
    Sencha User
    Join Date
    May 2012
    Location
    Bangalore
    Posts
    95
    Vote Rating
    1
    Rameshlamani is on a distinguished road

      0  

    Default


    @kalim i have tried your solution. it will work for list i need bind data to dataview panel from below Json object
    Hi i have given below proper code. i am not able to bind PromoUrl value to tpl from JSON. how to do this one. please any one can help me.

    Here is code:
    Code:
    Ext.define("GS.view.Twitter", {
        extend: 'Ext.navigation.View',
        xtype: 'twitter',
        requires: [
            'Ext.data.JsonP'
        ],
        config: {
            title: 'Blog',
            iconCls: 'star',
            items: {
                xtype: 'dataview',
                itemTpl: '{PromoUrl}',
                title: 'Recent Posts',
                store: {
                    autoLoad: true,
                    fields: ['PromoUrl'],
                    proxy: {
                        type: 'jsonp', 
                        url: 'pathlink', 
                        reader: {
                            type: 'json',
                            rootProperty: 'd'
                        }
                    }
                }
            }
        }
    });
    Here is Json:
    Code:
    { "d" : { "CompanyId" : 1,
          "ExceptionId" : 0,
          "PromoUrl" : "videos/Wildlife.mp4",
          "__type" : "Company:#ABC"
        } }

  9. #9
    Sencha User
    Join Date
    Jul 2013
    Posts
    2
    Vote Rating
    0
    httvhutceoscop is on a distinguished road

      0  

    Default


    You can read "Sencha Touch 2 Up and Running" book

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."