1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    33
    Answers
    2
    Vote Rating
    1
    Eugen_Max is on a distinguished road

      0  

    Default Unanswered: Filling nestedLists with custom JSON data and customizing tpl for leaf notes

    Unanswered: Filling nestedLists with custom JSON data and customizing tpl for leaf notes


    Hey guys,

    I have a question about nestedLists. First of all I want to fill my nestedList with JSON data. Let's say my JSON looks something like this:

    Code:
    {	"Group": [{
            "Id": 1,
            "key": "Product 1",
            "price": 20
        },
    	{
            "Id": 2,
            "key": "Product 2",
            "price": 30
        },
    	{
            "Id": 3,
            "key": "Product 3",
            "price": 12
        },
    	{
            "Id": 4,
            "key": "Product 4",
            "price":14
        }],
        "Id": 1,
        "key": "Product Categorie Name",
        "someKey": "whatever"
    }
    From my understanding, the nested list expects JSON data with the key "name". Can I config it so it uses for example "key" instead? Or would I have to parse the retreived JSON into a nestedList compatible format instead?

    Attached to this I wonder if I could tell my leaf notes to additonally display "price" in the list view, let's say right to the label?

    Thanks for reading,
    Eugen

  2. #2
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    San Antonio, TX
    Posts
    93
    Answers
    4
    Vote Rating
    0
    jnotti is on a distinguished road

      0  

    Default


    name is just used to identify a field. For example, my model:

    Code:
    Ext.define('App.model.UpdateProduct', {
        extend: 'Ext.data.Model',
    
    
        config: {
            fields: [
                {name: 'id', type: 'int'},
                {name: 'parent', type: 'int'},
                {name: 'type', type: 'string'},
                {name: 'status', type: 'string'},
                {name: 'title', type: 'string'},
                {name: 'content', type: 'auto'},
                {name: 'date', type: 'string'},
                {name: 'modified', type: 'string'},
                {name: 'tags', type: 'string'},
                {name: 'template', mapping: 'custom_fields.mobile_template'},
                {name: 'leaf', type: 'auto'},
            ],
            proxy: {
                type: 'ajax',
                id: 'UpdateProduct',
                url: 'data/get_mobile_index.json', 
                reader: {
                    type: 'json',
                    rootProperty: 'pages'
                }
            }
        }
    });
    Will consume JSON like this:

    Code:
    {
       "status":"ok",
       "pages":[
          {
             "id":1,
             "parent":0,
             "type":"page",
             "slug":"Product 1",
             "url":"http:\/\/localhost\/MCMS\/?page_id=8",
             "status":"publish",
             "title":"Product 1",
             "title_plain":"Product 1",
             "content":"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel eros ipsum. In non odio hendrerit felis tristique mollis eget at velit. Maecenas porttitor faucibus pretium. Etiam tincidunt nibh vel lacus tempor sed aliquam ipsum molestie. Fusce rhoncus fermentum massa, eu mattis turpis scelerisque sit amet. Sed diam nisi, vehicula tempus placerat in, blandit id lacus. Curabitur rutrum enim ac leo convallis imperdiet. Curabitur a libero justo, vel consequat dui. Sed mollis feugiat purus. Integer fringilla, lorem at pretium egestas, felis diam ultricies velit, a pulvinar neque nisl eu urna. Integer nec mauris urna, eget porttitor erat. Maecenas gravida ullamcorper tellus id ullamcorper. Morbi vitae ipsum elementum tellus viverra rhoncus id consectetur nunc.<\/p>\n",
             "excerpt":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel eros ipsum. In non odio hendrerit felis tristique mollis eget at velit. Maecenas porttitor faucibus pretium. Etiam tincidunt nibh vel lacus tempor sed aliquam ipsum molestie. Fusce rhoncus fermentum massa, &hellip; <a href=\"\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a>",
             "date":false,
             "modified":"2012-01-30 19:42:32",
             "categories":[
    
    
             ],
             "tags":[
    
    
             ],
             "author":{
                "id":1,
                "slug":"admin",
                "name":"admin",
                "first_name":"",
                "last_name":"",
                "nickname":"admin",
                "url":"",
                "description":""
             },
             "comments":[
    
    
             ],
             "attachments":[
    
    
             ],
             "comment_count":0,
             "comment_status":"open",
             "custom_fields":{
                "mobile_template":[
                   "product"
                ]
             }
          },
          {
             "id":2,
             "parent":1,
             "type":"page",
             "slug":"product 2",
             "url":"http:\/\/localhost\/MCMS\/?page_id=8",
             "status":"publish",
             "title":"Product 2",
             "title_plain":"Product 2",
             "content":"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel eros ipsum. In non odio hendrerit felis tristique mollis eget at velit. Maecenas porttitor faucibus pretium. Etiam tincidunt nibh vel lacus tempor sed aliquam ipsum molestie. Fusce rhoncus fermentum massa, eu mattis turpis scelerisque sit amet. Sed diam nisi, vehicula tempus placerat in, blandit id lacus. Curabitur rutrum enim ac leo convallis imperdiet. Curabitur a libero justo, vel consequat dui. Sed mollis feugiat purus. Integer fringilla, lorem at pretium egestas, felis diam ultricies velit, a pulvinar neque nisl eu urna. Integer nec mauris urna, eget porttitor erat. Maecenas gravida ullamcorper tellus id ullamcorper. Morbi vitae ipsum elementum tellus viverra rhoncus id consectetur nunc.<\/p>\n",
             "excerpt":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel eros ipsum. In non odio hendrerit felis tristique mollis eget at velit. Maecenas porttitor faucibus pretium. Etiam tincidunt nibh vel lacus tempor sed aliquam ipsum molestie. Fusce rhoncus fermentum massa, &hellip; <a href=\"\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a>",
             "date":false,
             "modified":"2012-01-30 19:42:32",
             "categories":[
    
    
             ],
             "tags":[
    
    
             ],
             "author":{
                "id":1,
                "slug":"admin",
                "name":"admin",
                "first_name":"",
                "last_name":"",
                "nickname":"admin",
                "url":"",
                "description":""
             },
             "comments":[
    
    
             ],
             "attachments":[
    
    
             ],
             "comment_count":0,
             "comment_status":"open",
             "custom_fields":{
                "mobile_template":[
                   "product"
                ]
             }
          }
       ]
    }
    I would highly recommend that you follow some of the tutorials located in the documentation. Also note that the above code is not the complete implementation, you would need a controller, a store and a view to display the data.

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    33
    Answers
    2
    Vote Rating
    1
    Eugen_Max is on a distinguished road

      0  

    Default


    Thanks for your reply. I think I got the basics of Sencha already. This question concerns an app I am currently developing. And ofc I have models,stores,views and controllers setup.

    I am actually asking specificly about this nestedList case. I want to know what format the store property of the nestedList component needs to be like... and if I can alter it.

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar