Results 1 to 5 of 5

Thread: Render Ext buttons into rendered DataView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Sep 2010
    Posts
    14

    Default Render Ext buttons into rendered DataView

    I would like to render buttons...
    Code:
    	var sharerPrevButton = new Ext.Button({
    		text: '<-',
    		myStore: sharerStore,
    		handler: function(b, e) {
    			b.myStore.changeThumbnail(false)
    		}
    	})
    	var sharerNextButton = new Ext.Button({
    		text: '->',
    		myStore: sharerStore,
    		handler: function(b, e) {
    			b.myStore.changeThumbnail(true)
    		}
    	})
    to the the template of the dataview...
    Code:
    	var sharerExtraTpl = new Ext.XTemplate([
    		'<tpl for=".">',
    		'<div float:left>',
    		'<img src="{thumbnailURL}" alt="{title} />',
    		'<div id="sharerWindowThumbnailPrev"></div>',
    		'<div id="sharerWindowThumbnailNext"></div>',
    		'</div>',
    		'<div><h1>{title}</h1></div>',
    		'<div>{description}</div>',
    		'</tpl>'
    	])
    (although there's a for loop, there's always only 1 record)
    ... I have an event for my store on load...
    Code:
    	sharerStore.on('load', function(r, o) {
    		console.info('load')
    		console.info(sharerPrevButton)
    		console.info(document.getElementById('sharerWindowThumbnailPrev'))
    	})
    but it doesn't ever see document.getElementById('sharerWindowThumbnailPrev')
    how do I render into dataview? neither of the rendered divs with ids are ever seen.

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

    Default

    If you don't do this carefully you will create memory leaks.

    I recommend using a ComponentDataView (see User extensions forum).

  3. #3
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    Also, read your template. float:left is meaningless.

    And you have hardcoded element IDs which is a bad idea.

  4. #4
    Sencha User
    Join Date
    Sep 2010
    Posts
    14

    Default

    May I know why?
    I'll try to be careful

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

    Default

    The id="sharerWindowThumbnailPrev" and id="sharerWindowThumbnailNext" divs are replicated for every record. This will generate you invalid HTML, because ids need to be unique.

    Also, getElementById will fail, because it will only return the first occurance of the id.

Similar Threads

  1. DataView triggers 'render' event when XTemplates not rendered yet
    By fetchinson in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 2 Jan 2010, 1:48 PM
  2. [CLOSED][3.??] Ext.DataView isnt rendered with IE8
    By defcon1 in forum Ext 3.x: Bugs
    Replies: 1
    Last Post: 16 Nov 2009, 6:50 AM
  3. Add a panel to a Dynamically rendered DataView
    By FATAL1TY in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 21 Jul 2009, 3:59 AM
  4. Radiobox Buttons not rendered
    By lramos85 in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 11 Dec 2008, 7:01 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
  •