Results 1 to 6 of 6

Thread: Calling custom functions in XTemplate

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Mar 2012
    Vote Rating

    Default Answered: Calling custom functions in XTemplate

    I've defined a custom function in an XTemplate, but when the page loads, I see:
    Uncaught Error: [ERROR][Ext.XTemplate#apply] Cannot read property 'calcDuration' of undefined

    My template is included below. What needs to be done to reference the function in the template? (Note: this template is in an object applied to a parent class. I'm not sure if that matters. The rest of the information is displayed correctly as long as I don't include the duration function.

                itemTpl : new Ext.XTemplate([
                    '<tpl for=".">',
                    '<div class="formBody meeting">',
                    '    <div class="label">Name</div>',
                    '    <div class="field">{meetingName}</div>',
                    '    <div class="label meetingDate">Date</div>',
                    '    <div class="label meetingStartTime">Start Time</div>',
                    '    <div class="label meetingDuration">Duration (optional)</div>',
                    '    <div class="field meetingDate">{meetingDate}</div>',
                    '    <div class="field meetingStartTime">{meetingStartTime}</div>',
                    '    <div class="field meetingDuration">',
                    '        { [this.calcDuration(values.meetingStartTime, values.meetingEndTime)] }',
                    '    </div>',
                    '    <div class="label">Meeting Location (optional)</div>',
                    '    <div class="field">{meetingLocation}</div>',
                    '    <div class="label">General Information (optional)</div>',
                    '    <div class="field">{comments}</div>',                
                        calcDuration: function(meetingStartTime, meetingEndTime) {
                            if (meetingStartTime && meetingEndTime) {
                              /* convert meetingTimes to 24h format */
                             /* subtract meetingStartTime from meetingEndTime */
                            } else {
                                returnString = '(unspecified)';
                            return returnString;

  2. I had formatted my function call as { [ ] } instead of {[ ]} (note spaces between curly and square braces).

Tags for this Thread

Posting Permissions

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