Results 1 to 4 of 4

Thread: Format textfield in combobox like in tpl

  1. #1
    Sencha User
    Join Date
    Apr 2008
    Posts
    365

    Default Format textfield in combobox like in tpl

    Hello!

    I have a combobox for which the user should pick a value out of the list. The list is formatted via a tpl like:

    / (Homepage)
    /page1.htm (Page1)
    /page2.htm (Page2)
    /page6.htm (Page6)

    The problem is: After selecting a value from this, the textfield only shows
    /page1.htm
    but I want it to show:
    /page1.htm (Page1)
    (so we have the values of 2 fields in it, including some html-formatting)

    Is there any way to do so?

    Code:
    {
    xtype: 'combo',
    value:'/page1.htm",
    hiddenValue: '1',
    name: 'id_visible',
    typeAhead: true,
    forceSelection: true,
    triggerAction: 'all',
    minChars:3,
    selectOnFocus: true,
    displayField:'url',
    valueField:'id',
    hiddenName:'id_post',
    tpl: '<tpl for=\".\"><div class=\"x-combo-list-item\"><i>{url}</i> ({name})</div></tpl>',
    store:	new Ext.data.Store(
    {	autoLoad: true,     
    	proxy: new Ext.data.HttpProxy(
    	{	url: '/get_store.php', 
    		method: 'POST'
    	}),
    	reader: new Ext.data.ArrayReader(
    	{	root: 'data',
    		totalProperty: 'total',
    		id: 0
    	}, 												 
    	[	{ name: 'id', type: 'string' },
    		{ name: 'url', type: 'string' },
    		{ name: 'name', type: 'string' }
    	])
    })
    }

  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    You should probably use the field convert function to setup a field that merges the values for the displayField.

  3. #3
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    The CalcRecord extension can also be useful here to add an extra calculated field that can be used as displayField.

  4. #4
    Sencha User
    Join Date
    Apr 2008
    Posts
    365

    Default

    Thanks for your replys, both solutions are working fine so far when loading values/hiddenValues from the store.

    But I got one last problem: When setting the value/hiddenValue out of the code, you normally use setValue. But that will set both the value and the hiddenValue to the same text. How do I set 2 values (the displayed value to "/page1.htm (Page1)" and the hidden value/submitted value to an id like "1234"). Whats the way to do that?

Similar Threads

  1. [CLOSED] creating tpl format in new version 0.99 not working
    By avishek1 in forum Sencha Touch 1.x: Bugs
    Replies: 2
    Last Post: 9 Nov 2010, 10:02 AM
  2. Format date in tpl
    By kortovos in forum Sencha Touch 1.x: Discussion
    Replies: 2
    Last Post: 21 Sep 2010, 1:17 AM
  3. Filtering ComboBox with tpl
    By shubakk in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 9 Nov 2009, 2:05 AM
  4. CSS issue w/ comboBox tpl, IE 6 only
    By karieanis in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 21 Jan 2009, 1:35 PM
  5. Combobox and tpl option
    By bitman in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 20 Oct 2008, 2:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •