[CLOSED] XTemplate + custom javascript function

  1. #1

    [CLOSED] XTemplate + custom javascript function

    Hi,

    I would like to replace the REFERENCE_CLUB by the related club name from an existing store.

    I tryied this way but doesnt work.
                                                            <ItemTpl runat="server">                                                            
                                                                <Html>                                                                
                                                                    <tpl for=".">                                                                    
                                                                        <div class="list-item" id="{ID}">                                                                                                                    
                                                                            <h3>{FULLNAME}</h3>
                                                                            <div class="Warn">{REFERENCE_CLUB:ClubRenderer}</div>
                                                                        </div>
                                                                    </tpl>                                            
                                                                </Html>
                                                            </ItemTpl>
    How can I call a javascript function?

    Thank you
    Last edited by Daniil; Feb 07, 2013 at 3:46 AM. Reason: [CLOSED]
  2. #2
    Hello!

    Take a look at the following example:

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            List<Parent> parents = new List<Parent>(3);
    
            for (int i = 0; i < 3; i++)
            {
                Parent parent = new Parent();
                parent.Name = "Parent" + i;
                    
                parents.Add(parent);
            }
    
            this.ObjHolder1.Items.Add("parents", parents);
        }
    
        public class Parent
        {
            public string Name { get; set; }
        }
    </script>
    
    <!DOCTYPE html>
       
    <html>
    <head runat="server">
        <title>Ext.NET Examples</title>    
        
        <script>
             var myFunction = function (name) {
                 return name + '_changed';
             };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:ObjectHolder ID="ObjHolder1" runat="server" />
             
            <ext:XTemplate ID="XTemplate1" runat="server">
                <Functions>
                    <ext:JFunction Name="MyFunction" Fn="myFunction" />
                </Functions>
                <Html>
    				<p>Name: {Name}</p>
                    {[this.MyFunction(values.Name)]}
    			</Html>
            </ext:XTemplate>
            
            <ext:Panel runat="server" >
                <Listeners>
                    <Render Handler="#{XTemplate1}.overwrite(this.body, #{ObjHolder1}.parents[0]);" />
                </Listeners>
            </ext:Panel>
        </form>
    </body>
    </html>
  3. #3
    Excellent,

    Yous support is like the Tina Turner's song : "Simply the best"

    Any workaround for calling a js function in a <ItemTpl> used in a combobox?

    It doesn't support custom functions as shown in you previous post.

    Thank you.
  4. #4
    Just define js function in the page and use it inside template without 'this'
    {[MyFunction(values.Name)]}

Similar Threads

  1. Replies: 4
    Last Post: Nov 27, 2012, 1:17 PM
  2. Calling JavaScript function
    By UserClarion in forum 1.x Help
    Replies: 2
    Last Post: Dec 30, 2011, 10:23 AM
  3. Call JavaScript function with CellSelection
    By bolzi89 in forum 1.x Help
    Replies: 5
    Last Post: Dec 23, 2011, 2:42 PM
  4. Replies: 8
    Last Post: Dec 23, 2011, 12:41 PM
  5. [CLOSED] Custon X.Msg.Show
    By stoque in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 10, 2011, 10:05 PM

Posting Permissions