PDA

View Full Version : [CLOSED] AjaxProxy Problem with Date fields on update



mtsig
Jul 25, 2013, 1:25 PM
Hello again,

in the store example below we have a problem with the update calls to the server.
The problem is that when you have a date field on a grid and you edit the field by setting its value to null and then do a sync, the ajaxproxy does not include the date field (and it's null value) in the updated header parameters.
This behavior only happens to date fields. On string and boolean fields that i have tested, it works fine.
This is a big problem because there is no way to know when you need to update the date field.

This works fine in extjs version 4.2.
Ext.Net version is 2.2


<ext:Store ID="store_users" runat="server" AutoSync="false" RemoteSort="true" RemoteFilter="true" PageSize="20" >
<Model>
<ext:Model ID="model_users" runat="server" IDProperty="UserId">
<Fields>
<ext:ModelField Name="UserId" Type="String" />
<ext:ModelField Name="UserDateCreated" Type="Date" />
<ext:ModelField Name="UserLoginName" Type="String" />
<ext:ModelField Name="UserLastName" Type="String" />
<ext:ModelField Name="UserFirstName" Type="String" />
<ext:ModelField Name="UserPersonName" Type="String" />
<ext:ModelField Name="UserEMail" Type="String" />
<ext:ModelField Name="UserActive" Type="Boolean" />
<ext:ModelField Name="UserDeleted" Type="Boolean" />
<ext:ModelField Name="UserDomain" Type="String" />
<ext:ModelField Name="UserLastNameGR" Type="String" />
<ext:ModelField Name="UserFirstNameGR" Type="String" />
</Fields>
<Proxy>
<ext:AjaxProxy Json="true" Url="users.ashx" >
<Reader>
<ext:JsonReader Root="data" SuccessProperty="success" MessageProperty="message" TotalProperty="total" />
</Reader>
<Writer>
<ext:JsonWriter Encode="true" WriteAllFields="true" Root="data" AllowSingle="false" />
</Writer>
<Listeners>
<Exception Fn="proxy_sync_error" />
</Listeners>
</ext:AjaxProxy>
</Proxy>
</ext:Model>
</Model>


</ext:Store>

<ext:Viewport ID="Viewport1" runat="server" Layout="BorderLayout">
<Items>
<ext:GridPanel
ID="GridPanel1" runat="server" Region="Center" Title="Users" ForceFit="true"
StoreID="store_users"
Frame="true">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button ID="Button5" runat="server" Text="Load" Icon="ArrowRefresh">
<Listeners>
<Click Handler="#{store_users}.load();" />
</Listeners>
</ext:Button>
<ext:Button ID="Button1" runat="server" Text="Insert" Icon="Add">
<Listeners>
<Click Handler="#{store_users}.insert(0, {}); #{GridPanel1}.editingPlugin.startEditByPosition({r ow:0, column:0});" />
</Listeners>
</ext:Button>

<ext:Button ID="btnDelete" runat="server" Text="Delete" Icon="Delete" Disabled="true">
<Listeners>
<Click Handler="#{GridPanel1}.deleteSelected();
if (!#{GridPanel1}.hasSelection()) {
#{btnDelete}.disable();
}" />
</Listeners>
</ext:Button>

<ext:Button ID="Button2" runat="server" Text="Save" Icon="Disk">
<Listeners>
<Click Fn="save" />
</Listeners>
</ext:Button>

<ext:Button ID="Button3" runat="server" Text="Clear" Icon="Cancel">
<Listeners>
<Click Handler="#{GridPanel1}.getSelectionModel().deselectAll();;
if (!#{GridPanel1}.hasSelection()) {
#{btnDelete}.disable();
}" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ID="Column1" runat="server" DataIndex="UserId" Text="UserID" Visible="false" />

<ext:Column ID="Column2" runat="server" DataIndex="UserLoginName" Text="Login Name">
<Editor>
<ext:TextField ID="TextField2" runat="server" />
</Editor>
</ext:Column>
<ext:Column ID="Column3" runat="server" DataIndex="UserLastName" Text="Last Name">
<Editor>
<ext:TextField ID="TextField3" runat="server" />
</Editor>
</ext:Column>
<ext:Column ID="Column4" runat="server" DataIndex="UserFirstName" Text="First Name">
<Editor>
<ext:TextField ID="TextField1" runat="server" />
</Editor>
</ext:Column>
<ext:Column ID="Column5" runat="server" DataIndex="UserPersonName" Text="Person Name">
<Editor>
<ext:TextField ID="TextField4" runat="server" />
</Editor>
</ext:Column>
<ext:Column ID="Column6" runat="server" DataIndex="UserEMail" Text="Email" Editable="true" >
<Editor>
<ext:TextField ID="TextField5" runat="server" />
</Editor>
</ext:Column>

<ext:CheckColumn ID="Column7" runat="server" DataIndex="UserActive" Text="Active" Editable="true" Width="50" />
<ext:CheckColumn ID="Column8" runat="server" DataIndex="UserDeleted" Text="Deleted" Editable="true" Width="50" />

<ext:Column ID="Column9" runat="server" DataIndex="UserDomain" Text="Domain" Width="50">
<Editor>
<ext:TextField ID="TextField8" runat="server" />
</Editor>
</ext:Column>
<ext:Column ID="Column10" runat="server" DataIndex="UserLastNameGR" Text="Last Name GR">
<Editor>
<ext:TextField ID="TextField9" runat="server" />
</Editor>
</ext:Column>
<ext:Column ID="Column11" runat="server" DataIndex="UserFirstNameGR" Text="First Name GR">
<Editor>
<ext:TextField ID="TextField10" runat="server" />
</Editor>
</ext:Column>

<ext:DateColumn ID="Column12" runat="server" DataIndex="UserDateCreated" Text="Created" Format="dd/MM/yyyy" >
<Editor>
<ext:DateField ID="TextField11" runat="server" />
</Editor>
</ext:DateColumn>
</Columns>
</ColumnModel>

<Features>
<ext:GridFilters ID="GridFilters1" runat="server">
<Filters>
<ext:StringFilter DataIndex="UserLoginName" />
<ext:StringFilter DataIndex="UserLastName" />
<ext:StringFilter DataIndex="UserFirstName" />
<ext:StringFilter DataIndex="UserPersonName" />
<ext:StringFilter DataIndex="UserEmail" />
<ext:BooleanFilter DataIndex="UserActive" />
<ext:BooleanFilter DataIndex="UserDeleted" />
<ext:StringFilter DataIndex="UserDomain" />
<ext:StringFilter DataIndex="UserLastNameGR" />
<ext:StringFilter DataIndex="UserFirstNameGR" />
<ext:DateFilter DataIndex="UserDateCreated" >
<DatePickerOptions runat="server" TodayText="Now" />
</ext:DateFilter>
</Filters>
</ext:GridFilters>
</Features>

<SelectionModel>
<ext:CheckboxSelectionModel >
<Listeners>
<Select Handler="#{btnDelete}.enable();" />
<Deselect Handler="if (!#{GridPanel1}.selModel.hasSelection()) { #{btnDelete}.disable(); }" />
</Listeners>
</ext:CheckboxSelectionModel>
</SelectionModel>
<BottomBar>
<ext:PagingToolbar ID="PagingToolbar4" runat="server"
DisplayInfo="true" DisplayMsg="Προβολή εγγραφών {0} - {1} of {2}"
EmptyMsg="">
</ext:PagingToolbar>
</BottomBar>
<Plugins>
<ext:CellEditing ID="CellEditing1" runat="server" ClicksToEdit="1" />
</Plugins>

</ext:GridPanel>
</Items>
</ext:Viewport>

Daniil
Jul 25, 2013, 2:43 PM
Hi @mtsig,

Please set up SubmitEmptyValue.

<ext:ModelField Name="UserDateCreated" Type="Date" SubmitEmptyValue="Null" />

mtsig
Jul 25, 2013, 3:06 PM
Thanks a lot, it works fine.


Hi @mtsig,

Please set up SubmitEmptyValue.

<ext:ModelField Name="UserDateCreated" Type="Date" SubmitEmptyValue="Null" />