Results 1 to 5 of 5

Thread: Using template with Ext.form.Checkbox

  1. #1
    Sencha User
    Join Date
    Dec 2008
    Posts
    3

    Default Using template with Ext.form.Checkbox

    Hello!
    I want to apply a custom template for rendering the Checkbox label (i.e. the boxLabel). I can see that the "tpl" config option exists (together with the "data" and "tplWriteMode"), but setting them doesn't affect the Checkbox rendering. What's wrong? Here is the code (it's Radio, but it doesn't matter):

    Code:
    	var radioBoxTemplate = new Ext.XTemplate
    	(
    		'<tpl for=".">',
    		'<div class="layout-radiobox-template">',
    		'	<div class="layout-radiobox-template-name">{name}</div>',
    		'	<div class="layout-radiobox-template-img"><img src="/images/layouts/{img}" /></div>',
    		'	<div class="layout-radiobox-template-desc">{desc}"</div>',
    		'</div>',
    		'</tpl>'
    	);
    
    	var cbg = new Ext.form.RadioGroup(
    	{
    		columns		: 1,
    		items		:
    		[
    			{
    				name	: 'a',
    				data	:
    				{
    					name	: 'name1',
    					img	: 'img1',
    					desc	: 'desc1'
    				},
    				tpl	: radioBoxTemplate
    			},
    			{
    				name	: 'a',
    				data	:
    				{
    					name	: 'name2',
    					img	: 'img2',
    					desc	: 'desc2'
    				},
    				tpl	: radioBoxTemplate
    			}
    		]
    	});
    Thank you!

    PS: How to enable syntax highlighting?

  2. #2
    Sencha Premium Member steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,675

    Default

    there is no property tpl for radiogroup/checkbox group!
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  3. #3
    Sencha User
    Join Date
    Dec 2008
    Posts
    3

    Default

    First, according to the ExtJS 3.3 API Docs, there IS a tpl and related config options (defined in Component superclass).
    Second, I am NOT using the tpl config option for Checkbox/RadioGroup, but for the *items* config option - i.e. I am using the tpl config option for Checkbox/Radio components (and not Groups).

    I can see from the source, that going up the prototype chain, finally the Ext.Component.render() is called ( Ext.form.Field and Ext.formCheckbox do not override it ) and it contains the code for rendering the component with a template defined:

    Code:
     if (this.tpl) {
                    if (!this.tpl.compile) {
                        this.tpl = new Ext.XTemplate(this.tpl);
                    }
                    if (this.data) {
                        this.tpl[this.tplWriteMode](contentTarget, this.data);
                        delete this.data;
                    }
                }
    So, I expect the template to be rendered somehow (even "wrong"), but nothing happens.

    I've added some debugging lines:
    Code:
     if (this.tpl) {
    				console.log('Tpl exist')
                    if (!this.tpl.compile) {
                        this.tpl = new Ext.XTemplate(this.tpl);
                    }
                    if (this.data) {
    					console.log('data exist')
                        this.tpl[this.tplWriteMode](contentTarget, this.data);
                        delete this.data;
    					console.dir(contentTarget)
                    }
                }
    And everything seems fine - the two log lines exist, and the ids of the components are properly set.

  4. #4
    Sencha User
    Join Date
    Dec 2008
    Posts
    3

    Default

    Anyone?

  5. #5
    Sencha Premium User
    Join Date
    Sep 2010
    Location
    UK
    Posts
    135

    Default Image label for checkbox

    I try to put a image label next to a checkbox using Template but can't get it to work either.

    Can anyone help?

    Thanks in advance
    Joe

Similar Threads

  1. form in a template
    By Severance in forum Sencha Touch 1.x: Discussion
    Replies: 7
    Last Post: 18 Jan 2013, 1:40 AM
  2. Replies: 2
    Last Post: 22 Jul 2010, 6:33 AM
  3. Help needed !! Template Form
    By fredleput in forum Ext 1.x: Help & Discussion
    Replies: 7
    Last Post: 30 Jul 2007, 8:13 AM
  4. Need: Example on Ext.form together with template
    By Joche in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 24 Apr 2007, 5:13 PM

Posting Permissions

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