Results 1 to 9 of 9

Thread: Template.append doesn't seem to be returning anything, ever

  1. #1
    Ext GWT Premium Member
    Join Date
    Mar 2007
    Posts
    12

    Default Template.append doesn't seem to be returning anything, ever

    I am setting the options "return Element" parameter true on template append. It never seems to return anything, but the text renders just fine.

    this.celltempl = new YAHOO.ext.DomHelper.Template('<span class="ygrid-col ygrid-col-{col} {lst}"><span class="ygrid-cell-text">{val}</span></span>');

    then, later, after setting values:
    newcell = this.celltempl.append(row,{col: colIndex, lst: lst, val: val},true);
    if (newcell) {
    alert(newcell);
    }

    never happens.... always null?

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854

    Default

    Is 'row' a valid HTML element?

  3. #3
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    6,956

    Default

    There has to be something else wrong. I use this method extensively. Can you show any more code?

  4. #4
    Ext GWT Premium Member
    Join Date
    Mar 2007
    Posts
    12

    Default

    Code:
    YAHOO.ext.grid.HMParameterGridView = function() {
    	YAHOO.ext.grid.HMParameterGridView.superclass.constructor.call(this);
    		this.celltempl = new YAHOO.ext.DomHelper.Template('<span class="ygrid-col ygrid-col-{col} {lst}"}><span class="ygrid-cell-text">{val}</span></span>');
    		//this.celltempl.compile();
    	};
    YAHOO.extendX(YAHOO.ext.grid.HMParameterGridView, YAHOO.ext.grid.GridView, {
    	renderRow: function(dataModel, row, rowIndex, colCount, renderers) {
    			 for(var colIndex = 0; colIndex < colCount; colIndex++){
    			  		if ((dataModel.renderers) && dataModel.renderers[rowIndex]){
    						val = renderers[colIndex](dataModel.getValueAt(rowIndex, colIndex), rowIndex, colIndex);};
    					if (val === '') {val = ''}
    					lst = colIndex == colCount-1 ? ' ygrid-col-last' : '';
    					newcell = this.celltempl.append(getEl(row),{col: colIndex, lst: lst, val: val},true);
    					if (newcell) {
    						alert(newcell);
    					}
    	        	}
    } etc....
    I spared the continuation of the details... but that's it. I do not really mean to have an alert there , just testing. The point is that everything renders just fine... just no return element.

  5. #5
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    6,956

    Default

    this.celltempl.append(getEl(row),{col: colIndex, lst: lst, val: val},true);

    should be:

    this.celltempl.append(row,{col: colIndex, lst: lst, val: val},true);

    DomHelper doesn't take YAHOO.ext.Element objects (although it probably should).

  6. #6
    Ext GWT Premium Member
    Join Date
    Mar 2007
    Posts
    12

    Default

    Of course it should not be getEl... I posted my Nth iteration of hacking this thing.
    Still no return if it's
    Code:
    newcell = this.celltempl.append(row,{col: colIndex, lst: lst, val: val},true);
    I know you use this function having looked at your code, and in general I am a big fan of yui-ext. So this little thing has me baffled.

  7. #7
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854

    Default

    Did you try wrapping that call in a try-catch or stepping into w/Firebug? Maybe an exception is being swallowed.

  8. #8
    Ext GWT Premium Member
    Join Date
    Mar 2007
    Posts
    12

    Default

    Code:
    				try
    					{
    						newcell = this.celltempl.append(row,{col: colIndex, lst: lst, val: val},true);
    					}
    					catch(err) {
    						alert(err.description);
    						
    					}
    					if (newcell) {
    						alert(newcell);
    					}
    - No error, no alert, no newcell returned.

  9. #9
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    6,956

    Default

    I think I know what it is. At the point you are trying to insert, the row has yet to be added to the DOM. It isn't added until after it is rendered. YAHOO.util.Dom (used by DomHelper for lookups) will fail on nodes that are not yet part of the document.

Similar Threads

  1. Ext.DomHelper.Template: one template, ten YUI grids
    By moraes in forum Community Discussion
    Replies: 11
    Last Post: 18 Dec 2012, 4:55 AM
  2. How to Ext.DomHelper.append ?
    By kimu in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 25 Mar 2007, 8:22 AM
  3. insertHtml not returning HTMLelement?
    By fecund in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 11 Mar 2007, 12:32 AM
  4. Ext.DomHelper.Template or Ext.Template?
    By mystix in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 1 Mar 2007, 3:05 PM
  5. findParent returning HTML Element
    By martin in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 28 Feb 2007, 9:31 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
  •