[CLOSED] Can a DateColumn be empty in GridPanel?

  1. #1

    [CLOSED] Can a DateColumn be empty in GridPanel?

    I have a GridPanel that has a few DateColumns. Mainly, they are for ModifiedDate, etc. but one of the columns is for an expiration date, something that may or may not be applicable for each row. Empty dates in our database are reflected as "1/1/1900 12:00am", which is what is being displayed in the grid.

    Is there a way, either through property or a renderer function to have a datecolumn be empty? Meaning, "if the date is 1/1/1900 12:00am, display empty string or null?

    I think this is pretty simplistic (more a capability question than a bug), so I didn't include an example...but if you'd like one, feel free to let me know and I'll be more than happy to include it!

    Thanks!
    Jason
    Last edited by Daniil; Oct 21, 2010 at 2:17 PM. Reason: [CLOSED]
  2. #2
    Ping...

    Any help here? I wanted to keep the column a DateColumn for sorting and filtering, but if it can't be empty, I may have to change to a template column or something else that can be empty conditionally...

    Thanks in advance!
    Jason
  3. #3
    Any update on this?
    Thanks,
    Jason
  4. #4
    Hi Jason,

    Apologize for the delay.

    We are focused on the Premium Help forum. I'm moving this thread to there.
    So, for the future please post any technical support questions on the Premium Help. Thank you.

    A DateColumn doesn't support a custom renderer because it uses an own one.

    There is a very simple renderer in a DateColumn.
    So, I would suggest you to use a common column with a custom renderer.
    Sorting and filtering features should work.

    Example
    <%@ 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[] {"01/01/2010"},
                                             new object[] {"01/01/1900"},
                                             new object[] {"02/02/2010"}
                                    };
                store.DataBind();
            }
        }
    </script>
     
    <!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>Ext.Net Example</title>
     
        <script type="text/javascript">
            var myDateRenderer = function(value) {
                value = Ext.util.Format.date(value,"m/d/Y");
                return (value == "01/01/1900") ? "Hello! Here is an empty date." : value;
            }
        </script>
     
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test" Type="Date" DateFormat="m/d/Y" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Header="Test" DataIndex="test" Width="200">
                        <Renderer Fn="myDateRenderer" />
                    </ext:Column>
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
        </form>
    </body>
    </html>
    Last edited by Daniil; Oct 20, 2010 at 10:45 AM. Reason: Editted example

Similar Threads

  1. [OPEN] [#98] GridPanel: date values in DateColumn not localized
    By sbg in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 27, 2012, 8:57 AM
  2. [CLOSED] display milliseconds in GridPanel DateColumn
    By uis_pm in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: May 28, 2012, 5:44 PM
  3. display milliseconds in GridPanel DateColumn
    By jimlahey in forum 1.x Help
    Replies: 0
    Last Post: Apr 06, 2011, 8:16 AM
  4. [CLOSED] Renderer does not work on DateColumn in GridPanel
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 04, 2011, 11:04 AM
  5. Replies: 11
    Last Post: Aug 27, 2010, 9:52 PM

Posting Permissions