PDA

View Full Version : [CLOSED] How to display an Asterisk(*) next to Tpl column



Fahd
Aug 23, 2012, 8:32 PM
Hi,
Can you please show me how to add an asterisk next to the template field if certain conditions are met. For example, in my code below, I would like to display an asterisk next to the {Description} column if ModelField "MASTEnabled" is "true".


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Web.test" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.PlantsStore.DataSource = this.Data;
this.PlantsStore.DataBind();
}
}

private object[] Data
{
get
{
return new object[]
{
new object[] { "3m Co", true },
new object[] { "Alcoa Inc", false },
new object[] { "Wal-Mart Stores, Inc.", true }
};
}
}
</script>


</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />

<form id="form1" runat="server">
<div>
<ext:Container ID="Container1" runat="server">
<Items>
<ext:Panel ID="Panel1" runat="server" MarginSpec="14 0 0 650" Border="false">
<Items>
<ext:ComboBox ID="txtPlants" runat="server" EmptyText="Select Plant" ForceSelection="true"
Icon="Building" FieldLabel="Plant" DisplayField="Description" Mode="Remote" ValueField="PlantId"
Editable="false">
<Store>
<ext:Store ID="PlantsStore" runat="server" AutoLoad="true" AutoDataBind="true">

<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="Description" Type="String" />
<ext:ModelField Name="MASTEnabled" Type="Boolean" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ListConfig Width="520" Height="300" ItemSelector=".x-boundlist-item">
<Tpl ID="Tpl1" runat="server">
<Html>
<tpl for=".">
<tpl if="[xindex] == 1">
<table class="cbDoughName-list">
<tr>
<th>Plant Name :</th>
<th>Enabled :</th>
</tr>
</tpl>
<tr class="x-boundlist-item">
<td style="Padding:3px 0px;">{Description}</td>
<td>{MASTEnabled}</td>
</tr>
<tpl if="[xcount-xindex]==0">
</table>
</tpl>
</tpl>
</Html>
</Tpl>
</ListConfig>
<Triggers>
<ext:FieldTrigger Icon="Clear" HideTrigger="true" />
</Triggers>
<Listeners>
<BeforeQuery Handler="this.getTrigger(0)[this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
<TriggerClick Handler="if(index == 0) { el.focus().clearValue(); trigger.hide(); }" />
<Select Handler="this.getTrigger(0).show();" />
</Listeners>

</ext:ComboBox>
</Items>
</ext:Panel>
</Items>
</ext:Container>
</div>
</form>
</body>
</html>

Vladimir
Aug 23, 2012, 8:38 PM
<td style="Padding:3px 0px;">
{Description}
<tpl if="MASTEnabled">
*
</tpl>
</td>


Please see the following sample to investigate template syntax
http://examples2.ext.net/#/Miscellaneous/XTemplate/Overview/

Fahd
Aug 23, 2012, 8:46 PM
Thank you! It works.




<td style="Padding:3px 0px;">
{Description}
<tpl if="MASTEnabled">
*
</tpl>
</td>


Please see the following sample to investigate template syntax
http://examples2.ext.net/#/Miscellaneous/XTemplate/Overview/