[CLOSED] Problem with TemplateColumn

  1. #1

    [CLOSED] Problem with TemplateColumn

    I want to use my tri-state checkbox in a GridPanel, I have attached the code example:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WFConfigIngressi.aspx.cs" Inherits="TestGoogleMaps.WFConfigIngressi" %>
    <%@ 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">
        <script type="text/javascript" src="js/tristate-0.9.2.js" ></script>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server">
          <ext:GridPanel ID="gpIngressi" runat="server" AutoHeight="True" Title="Title">
              <ext:Store ID="stGpIngressi" runat="server" GroupField="dePeriferica" >
                            <ext:RecordField Name="cdPeriferica" />
                            <ext:RecordField Name="dePeriferica" />
                            <ext:RecordField Name="tipoIngresso" />
                            <ext:RecordField Name="cdIngresso" />
                            <ext:RecordField Name="cdNrDato" />
                            <ext:RecordField Name="deIngresso" />
                            <ext:RecordField Name="checkValue" />
                            <ext:RecordField Name="idRow" />
                <SortInfo Field="dePeriferica" Direction="ASC" />
            <ColumnModel ID="cmGpIngressi" runat="server">
                    <ext:Column DataIndex="cdPeriferica" Header="cdPeriferica" Hidden="true" />
                    <ext:Column DataIndex="dePeriferica" Header="<b>Periferica</b>" Width="275px" />
                    <ext:Column DataIndex="tipoIngresso" Header="tipoIngresso" Hidden="true" />
                    <ext:Column DataIndex="cdIngresso" Header="cdIngresso" Hidden="true" />
                    <ext:Column DataIndex="cdNrDato" Header="cdNrDato" Hidden="true" />
                    <ext:Column DataIndex="deIngresso" Header="<b>Ingresso/Registro</b>" Width="275px" />
                   <ext:TemplateColumn DataIndex="checked" Header="CustomCol" Fixed="true" Sortable="false" ColumnID="checkCol" MenuDisabled="true" Width="65px">
                     <Template runat="server" >
                          <span id="tristateBox{idRow}" style="cursor: default;">
                         <input type="hidden" id="tristateBox{idRow}State" name="tristateBox{idRow}State" value="{checkValue}"/> 
                        <script type="text/javascript">
                          initTriStateCheckBox('tristateBox{idRow}', 'tristateBox{idRow}State', true);
            <LoadMask ShowMask="true" />
                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
                    GroupTextTpl='<span id="periferica_{[values.rs[0].data.cdPeriferica]}"></span>{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Ingressi" : "Ingresso"]})'
    Please help me.

    Last edited by Daniil; Nov 30, 2010 at 10:31 AM. Reason: [CLOSED]
  2. #2

    Please provide 'tristate-0.9.2.js'
    Vladimir Shcheglov
    Sr. Developer
  3. #3
    I have attached the file.
    Attached Files
  4. #4

    The TemplateColumn is not useful in this case because a markup is not rendered yet when the initTriStateCheckBox() function is executed.

    The substitution of TemplateColumn can be a common Column with custom Renderer.

    Please try something like this:

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
            if (!X.IsAjaxRequest)
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                    new object[] {"id1", true},
                    new object[] {"id2", false},
                    new object[] {"id3", true}
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
        <script type="text/javascript" src="Scripts/tristate-0.9.2.js"></script>
        <script type="text/javascript">
            var myRenderer = function(value, record) {
                var html = [],
                    idRow = record.get('idRow'); ;
                html.push('<span id="tristateBox' + idRow + '" style="cursor: default;">');
                html.push('<input type="hidden" id="tristateBox' + idRow + 'State" name="tristateBox' + idRow + 'State"');
                html.push('value="' + value + '"/>');
                if (!record.executed) {
                    initTriStateCheckBox.defer(100, this, ['tristateBox' + idRow, 'tristateBox' + idRow + 'State', true]);
                    record.executed = true;
                return html.join("");
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
                <ext:Store runat="server">
                                <ext:RecordField Name="idRow" />
                                <ext:RecordField Name="test" />
            <ColumnModel runat="server">
                    <ext:Column Header="id" DataIndex="idRow" />
                    <ext:Column Header="Test" DataIndex="test">
                        <Renderer Handler="return myRenderer(value, record);" />
  5. #5
    Hi Danil,
    I use your solution, it is perfect.
    Thank you very much.


Similar Threads

  1. Replies: 7
    Last Post: Jun 29, 2012, 1:22 PM
  2. Adding Dropdown box to TemplateColumn of GridPanel
    By Mrityunjay in forum 2.x Help
    Replies: 0
    Last Post: Jun 19, 2012, 9:41 AM
  3. [CLOSED] TemplateColumn Click Not Registering
    By peter.campbell in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 14, 2011, 12:24 PM
  4. [CLOSED] Embedding server tags in TemplateColumn
    By pj_martins in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 30, 2011, 1:39 PM
  5. [CLOSED] Renderer on a TemplateColumn: not working
    By capecod in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Dec 11, 2010, 12:34 AM

Tags for this Thread

Posting Permissions