Checkbox with Y/N values instead of true/false

  1. #1

    Checkbox with Y/N values instead of true/false

    Hello,

    I have a stupid question, but can find a solution for it.
    I have lots of reference tables in our Database that contains columns with Y/N value to indicate if the record is Active or Inactive.
    I want to load them into a Gridpanel and transform the Y/N values to a Boolean (True/False).
    Currently I have this columns defined as CheckColumn in the GridPanel.

    Thank you in advance.
  2. #2

    RE: Checkbox with Y/N values instead of true/false

    You could probably do something like this example.

    https://examples1.ext.net/#/GridPanel/ArrayGrid/Simple/


    Instead of changing the color based on the value though, you would change the text to 'Active' or 'Inactive' based on whether your boolean value is true or false.

    -MC
  3. #3

    RE: Checkbox with Y/N values instead of true/false

    Hi,

    You can use Convert function of RecordField. Please see the following sample:
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Ext.IsAjaxRequest)
            {
                this.Store1.DataSource = new object[]
                {
                    new object[] {"3m Co", 71.72, 0.02, 0.03, "Y"},
                    new object[] {"Alcoa Inc", 29.01, 0.42, 1.47, "Y"},
                    new object[] {"Altria Group Inc", 83.81, 0.28, 0.34, "N"},
                    new object[] {"Wal-Mart Stores, Inc.", 45.45, 0.73, 1.63, "N"}
                };
    
                this.Store1.DataBind();
            }
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Coolite Toolkit Example - Simple Array Grid</title>   
        
        <script type="text/javascript">
            function convert(v) {
                if (v == "Y") {
                    return true;
                }
    
                if (v == "N") {
                    return false;
                }
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
            
            <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="company" />
                            <ext:RecordField Name="price" Type="Float" />
                            <ext:RecordField Name="change" Type="Float" />
                            <ext:RecordField Name="pctChange" Type="Float" />
                            <ext:RecordField Name="active" Type="Boolean">
                                <Convert Fn="convert" />
                            </ext:RecordField>
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
            
            <ext:GridPanel 
                ID="GridPanel1" 
                runat="server" 
                StoreID="Store1" 
                StripeRows="true"
                Title="Array Grid" 
                TrackMouseOver="true"
                Width="600" 
                Height="350"
                AutoExpandColumn="Company">
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ColumnID="Company" Header="Company" Width="160" Sortable="true" DataIndex="company" />
                        <ext:Column Header="Price" Width="75" Sortable="true" DataIndex="price"/>
                        <ext:Column Header="Change" Width="75" Sortable="true" DataIndex="change"/>
                        <ext:Column Header="Change" Width="75" Sortable="true" DataIndex="pctChange"/>
                        <ext:CheckColumn Header="Active" Width="50" Sortable="true"  DataIndex="active"/>
                    </Columns>
                </ColumnModel>         
            </ext:GridPanel>  
        </form>
    </body>
    </html>

  4. #4

    RE: Checkbox with Y/N values instead of true/false

    Vlad,

    It works!
    Please mark it as [CLOSED]





    Thank you very much!

Similar Threads

  1. [CLOSED] Checkbox return true/false
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 04, 2011, 5:42 AM
  2. Replies: 4
    Last Post: Feb 21, 2011, 10:02 PM
  3. Replies: 0
    Last Post: May 04, 2010, 7:08 AM
  4. [CLOSED] Disabled Checkbox is always false and shows enabled true.
    By Sharon in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 12, 2009, 4:10 AM
  5. [CLOSED] textbox visible false&true
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 16, 2009, 9:57 AM

Posting Permissions