1. #1
    Sencha User
    Join Date
    Aug 2010
    Posts
    45
    Vote Rating
    0
    pajelawrence is on a distinguished road

      0  

    Default How to DataItem Id dynamically

    How to DataItem Id dynamically


    Hi,

    I have the same problem in DataItem. Moe specific I am using DataItem inside my DataView.
    The question is:
    1. How to set an Id on each DataItem?
    2. This ID's is dynamically from server.

    My idea is below.

    Code:
    config:{
    		cls: 'kitten-list-item',
    		action: 'freeStyleItem',
    		
    				
    		dataMap:{
    			setItemId: 'id', // This is What I mean. But it does not work, instead the ID was generated by the framework. "ext-layoutfreestyleitem-1"
    
    
    			getImage: {
    				setSrc: 'icon'
    			},
    			getName: {
    				setHtml: 'name'
    			}
    		},
    		image:true,
    		image:{
    			cls: 'x-img',
    			itemId: 'id'
    		},
    		name:{
    			cls: 'x-name',
    			flex: 1
    		}	
    	},
    Here is my JSON file

    Code:
    {
        "widgets": [
            {
                "order": 1,
                "id": "hey-297",
                "name": "Product and Services",
                "description": "Description soon!",
                "icon": "http://vegacrush.com/skyline/img/icongreen_badge.png",
                "edit": "arrow_right"
            },
            {
                "order": 2,
                "id": "296",
                "name": "Sencha touch",
                "description": "Description soon!",
                "icon": "http://skylinetest2.net/project2/assets/js/jquery/uploadify/features/1327899484-sub-icon-sencha-logo.jpg",
                "edit": "arrow_right"
            },
            {
                "order": 3,
                "id": "295",
                "name": "News Update",
                "description": "Description soon!",
                "icon": "http://skylinetest2.net/project2/assets/js/jquery/uploadify/upload/renz_logo.gif",
                "edit": "arrow_right"
            }
    ]
    }

    Please help me guys. Thank you in advanced

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,627
    Vote Rating
    435
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Why would you need to set the id or itemId? You can get the dataitem if you have the index of the record in the store.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

Tags for this Thread