View Full Version : [CLOSED] How can set DateColumn value with Javascript inside grid?

Feb 04, 2015, 8:38 AM
Requirement is on change of date i have to validate the selected date should not be greater than last column date value.
Below is my code

<ext:GridPanel ID="grdDates" runat="server" ButtonAlign="Center"
<ext:Store ID="strDates" runat="server" OnReadData="StrDates_OnRefreshData" >
<ext:Model IDProperty="MonthId" runat="server">

<ext:ModelField Name="M_Date" Type="Date" DateFormat="yyyy-MM-dd\THH:ss:mm" />
<ext:ModelField Name="C_Date" Type="Date" DateFormat="yyyy-MM-dd\THH:ss:mm" />
<ext:ModelField Name="S_Date" Type="Date" DateFormat="yyyy-MM-dd\THH:ss:mm" />

<ext:DateColumn ID="editMDateID" Text="MDate" DataIndex="M_Date" runat="server"
Width="175" Sortable="false" MenuDisabled="true" >
<ext:DateField ID="mDate" runat="server" AllowBlank="true" Editable="true" >

<ext:DateColumn ID="editCDateID" Text="Comments Freeze Date" DataIndex="C_Date" runat="server"
Width="175" Sortable="false" MenuDisabled="true" >
<ext:DateField ID="cDate" runat="server" AllowBlank="true" Editable="true" >
<ext:DateColumn ID="editSDateID" Text="Snapshot Date" DataIndex="S_Date" runat="server"
Width="175" Sortable="false" MenuDisabled="true" >
<ext:DateField ID="sDate" runat="server" AllowBlank="true" Editable="true" >
<ext:RowSelectionModel runat="server" />
<Plugins >
<ext:CellEditing ID="CellEditing1" runat="server">
<Edit Fn ="grid_OnEdit"></Edit>
<ext:GridView runat="server" MarkDirty="false" StripeRows="true"/>

and below is the function for same

function grid_OnEdit(editor, e) {
var mDate =new Date(e.record.data["Metrics_Date"]);
var cDate = e.record.data["Comments_Date"];
var sDate = e.record.data["Snapshot_Date"];
if(sDate < cDate || sDate <mDate)
//e.value = null;



now how to set either original value or clear the value ?

Feb 04, 2015, 2:18 PM
Hi @arjunrvasisht,

There is a CellEditing's ValidateEdit even that I would recommend you to use.