rendering date difference in a gridpanel column

  1. #1

    rendering date difference in a gridpanel column

    Hello, I've some problem rendering date difference in a gridpanel column.

    I'm trying to get difference (in days) between a date in the same row and today's date. But the return value is always "NaN".

    Is there something wrong with the handler?


    Here's my code,

    <body style="background-color: #DFE8F6">
        <form id="form1" runat="server">
         <ext:ResourceManager ID="ResourceManager1" runat="server" />
         <ext:Hidden ID="HiddenField1"  name ="HiddenField1" runat="server"></ext:Hidden>
         <ext:Hidden ID="HiddenField2"  name ="HiddenField2" runat="server"></ext:Hidden>
         <ext:Hidden ID="HiddenField3"  name ="HiddenField3" runat="server"></ext:Hidden>
        <div>
            
            <br />
            <table width="98%" align="center">
            <tr>
            <td>
            <ext:TabPanel ID="TabPanel1" runat="server" DeferredRender="false" Layout="ColumnLayout" Border="false" BodyStyle="background-color: #DFE8F6" Frame="true" Autoscroll="True" Anchor="100% 100%">
                <items>
                    <ext:Panel ID="Panel1" runat="server" Title="New">
                        <items>
                            <ext:GridPanel ID="GridPanel4" runat="server" Title="" overflow="auto" fitToFrame="true" Anchor="100% 100%">
                                <store>
                                    <ext:Store runat="server" ID="strNew">
                                        <Model>
                                            <ext:Model runat="server" ID="Model3">
                                                <Fields>
                                                    <ext:ModelField Name="ProjectID" Type="String" />
                                                    <ext:ModelField Name="CreateDate" Type="String"/>
                                                </Fields>
                                            </ext:Model>
                                        </Model>
                                    </ext:Store>
                                </store>
                                <ColumnModel>
                                    <Columns>
                                        <ext:Column ID="Column1" runat="server" Text="ProjectID" Width="80" DataIndex="ProjectID" />
                                        <ext:Column ID="Column7" runat="server" Text="Aging" Width="80">
                                            <Renderer handler="var today = Date.parse(Date.now()); var createdt = Date.parse(record.data.CreateDate); var diffDays = Math.round(parseInt(today-createdt) / (86400000));  return diffDays;" />
                                        </ext:Column>
                                        <ext:Column ID="Column13" runat="server" Text="Create Date" Width="100" DataIndex="CreateDate" />
                                    </Columns>
                                </ColumnModel>
                            </ext:GridPanel>
                        </items>
                    </ext:Panel>
                </items>
            </ext:TabPanel>
            </td>
            </tr>
            </table>
        </div>
        </form>
    </body>
    Thanks before.
  2. #2
    Just found the solution. I parsed the dates to integer first. Thanks anyway.


    <Renderer handler="var today = Date.now(); createdt = Date.parse(record.data.CreateDate); return Math.floor((parseInt(today)-parseInt(createdt))/(86400000));" />

Similar Threads

  1. Replies: 1
    Last Post: Apr 02, 2013, 5:51 AM
  2. Replies: 2
    Last Post: Jan 23, 2013, 2:24 PM
  3. Replies: 0
    Last Post: Sep 13, 2011, 3:25 PM
  4. [CLOSED] Gridpanel second Column data Rendering a Jiberish
    By SymSure in forum 1.x Premium Help
    Replies: 5
    Last Post: Apr 01, 2010, 5:35 PM
  5. Replies: 3
    Last Post: May 09, 2009, 12:15 PM

Tags for this Thread

Posting Permissions