PDA

View Full Version : [CLOSED] XTemplate + custom javascript function



bossun
Feb 03, 2013, 1:04 AM
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

Baidaly
Feb 03, 2013, 2:03 AM
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>

bossun
Feb 03, 2013, 11:43 AM
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.

Vladimir
Feb 03, 2013, 9:22 PM
Just define js function in the page and use it inside template without 'this'


{[MyFunction(values.Name)]}