[CLOSED] Model DateField on submit returns null

Page 2 of 2 FirstFirst 12
  1. #11
    Here it is:
    <!DOCTYPE html>
    
    <html>
    <head>
        <link type="text/css" rel="stylesheet" href="/TestSubmit/extjs/resources/ext_theme_gray/ext-theme-gray-all-embedded-css/ext.axd?v=10552" id="ext-theme" />
        <link type="text/css" rel="stylesheet" href="/TestSubmit/extnet/resources/css/extnet-all-embedded-css/ext.axd?v=10552" id="extnet-styles" />
        <script type="text/javascript" src="/TestSubmit/extjs/ext-all-js/ext.axd?v=10552"></script>
        <script type="text/javascript" src="/TestSubmit/extnet/extnet-all-js/ext.axd?v=10552"></script>
    
        <title>Index</title>
        <link rel="stylesheet" href="/TestSubmit/resources/css/examples.css" />
    	
        <style>
            .my_icon {
                background-image:url(../../Resources/EditTableHS.png)
            }
        </style>
        <script>
            Ext.onReady(function ()
            {
    
                Ext.get(window.document).on('contextmenu', function (e)
                {
                    e.preventDefault();
                    return false;
                });
                
            });
    
            function reloadGridPanel(grid, data) {
                grid.show(); 
                grid.getStore().loadData(data);
            };
    
    
            var onSuccessEdit = function (data, cmd) {
                switch (cmd) {
                    case "edit":
                        var record = App.objectsGrid.getSelectionModel().selected.items[0];
                        var index = App.objectsGrid.getStore().indexOf(record);
                        var r = App.objectsGrid.getStore().getAt(index);
                        r.beginEdit();
                        r.data = data;
                        r.endEdit();
                        r.commit();
                        break;
                    case "addnew":
                        var numRow = App.objectsGrid.getStore().getCount();
                        App.objectsGrid.getStore().insert(numRow, data);
                        break;
                    case "delete":
                        App.objectsGrid.deleteSelected();
                        break;
                }
            };
    
    
            var template = '<span style="color:{0};">{1}</span>';
    
            var change = function (value) {
                return Ext.String.format(template, (value) ? "green" : "red", value);
            };
    
            var tpl = "<img src='{0}' />";
    
            var booleanRenderer = function (value) {
                if (value == null || !value)
                    return "<img src=\"http://localhost/TestSubmit/Resources/cross.png\" />";
                else
                    return "<img src=\"http://localhost/TestSubmit/Resources/tick.png\" />";
            }
        </script>
    
    
        <script type="text/javascript">
        //<![CDATA[
            Ext.net.ResourceMgr.init({isMVC:true,theme:"gray",appName:"TestSubmit"});Ext.onReady(function(){Ext.ns("App.direct");Ext.apply(App.direct, { DoYes:function(id,config){return Ext.net.DirectMethod.request("DoYes",Ext.applyIf(config || {}, {params:{id:id},url:"/TestSubmit/Home/DoYes"}));} });Ext.create("Ext.grid.Panel",{store:{model:Ext.define(Ext.id(), {extend: "Ext.data.Model", fields:[{name:"IDProperty"},{name:"StringProperty"},{name:"BooleanProperty"},{name:"DateProperty"},{name:"IntegerProperty"},{name:"FloatProperty"}] }),storeId:"Store1",autoLoad:true,proxy:{data:[{"IDProperty":"123b60cf-6d9c-48d6-ac25-306724e7fd35","StringProperty":"string1","BooleanProperty":false,"DateProperty":"2015-10-02T09:08:22.7648922","IntegerProperty":18,"FloatProperty":123.2},{"IDProperty":"f9912604-f8ca-48fc-a97d-f6ba65b1b2c6","StringProperty":"string2","BooleanProperty":true,"DateProperty":"2015-10-01T09:08:22.7668916","IntegerProperty":19,"FloatProperty":234.2},{"IDProperty":"1393f792-0625-46f9-8b58-18c99bdc74ed","StringProperty":"string3","BooleanProperty":false,"DateProperty":"2015-10-03T09:08:22.7668916","IntegerProperty":11,"FloatProperty":345.2},{"IDProperty":"084e797e-6e74-4bf6-b296-b9b878bdde29","StringProperty":"string4","BooleanProperty":true,"DateProperty":"2015-09-30T09:08:22.7668916","IntegerProperty":13,"FloatProperty":456.2},{"IDProperty":"b65bb38a-0dc9-40b7-ad52-4883744eb0fb","StringProperty":"string5","BooleanProperty":false,"DateProperty":"2015-09-29T09:08:22.7668916","IntegerProperty":15,"FloatProperty":567.2}], type: 'memory'}},id:"objectsGrid",renderTo:"App.objectsGrid_Container",tbar:{xtype:"toolbar",items:[{iconCls:"#TableAdd",text:"Add object",directEvents:{click:{fn:function(item,e){Ext.net.directRequest({cleanRequest:true,url:"/TestSubmit/Home/AddObject",control:this});}}}},{iconCls:"#TableRefresh",text:"Refresh",directEvents:{click:{fn:function(item,e){Ext.net.directRequest({cleanRequest:true,url:"/TestSubmit/Home/Refresh",userSuccess:function(response,result,el,type,action,extraParams,o){reloadGridPanel(App.objectsGrid, result.data);},control:this});}}}},{iconCls:"#ImageAdd",text:"Import image",directEvents:{click:{fn:function(item,e){Ext.net.directRequest({cleanRequest:true,url:"/TestSubmit/Home/ImportImage",control:this});}}}}]},title:"MyObjects",columns:{items:[{width:300,dataIndex:"StringProperty",text:"Стринг проперти"},{width:300,dataIndex:"BooleanProperty",renderer:booleanRenderer,text:"BooleanProperty"},{width:300,xtype:"datecolumn",dataIndex:"DateProperty",text:"DateProperty",format:"j.n.Y."},{width:300,dataIndex:"IntegerProperty",text:"IntegerProperty"},{width:300,dataIndex:"FloatProperty",text:"FloatProperty"}]},listeners:{itemcontextmenu:{fn:function(item,record,node,index,e){e.preventDefault();App.ItemContextMenu.dataRecord=record.data;App.ItemContextMenu.showAt(e.getXY());}},viewready:{delay:100,fn:function(item){this.selModel.select(0);this.getView().focusCell({row:0, column:0});}}},directEvents:{itemdblclick:{fn:function(item,record,node,index,e){Ext.net.directRequest({cleanRequest:true,url:"/TestSubmit/Home/EditObject",extraParams:{"objectId":record.data.IDProperty},control:this,action:'ItemDblClick'});}}}});Ext.create("Ext.menu.Menu",{id:"ItemContextMenu",items:[{iconCls:"#TableEdit",text:"Edit object",directEvents:{click:{fn:function(item,e){Ext.net.directRequest({cleanRequest:true,url:"/TestSubmit/Home/EditObject",extraParams:{"objectId":this.parentMenu.dataRecord.IDProperty},control:this});}}}},{iconCls:"#Lightning",text:"Switch boolean property",directEvents:{click:{fn:function(item,e){Ext.net.directRequest({cleanRequest:true,url:"/TestSubmit/Home/SwitchBool",extraParams:{"objectId":this.parentMenu.dataRecord.IDProperty},control:this});}}}},{xtype:"menuseparator"},{iconCls:"#TableDelete",text:"Delete object",directEvents:{click:{fn:function(item,e){Ext.net.directRequest({cleanRequest:true,url:"/TestSubmit/Home/DeleteObject",extraParams:{"objectId":this.parentMenu.dataRecord.IDProperty},control:this});}}}}]});Ext.net.ResourceMgr.registerIcon(["TableAdd","TableRefresh","ImageAdd","TableEdit","Lightning","TableDelete"]);});
        //]]>
        </script>
    </head>
    <body>
          
          
        <div id="App.objectsGrid_Container"></div>
            
        
    
    </body>
    </html>
  2. #12
    Ok, I just got that a FormPanel is being rendered on the fly as a partial view. I tried such a scenario and, seems, it didn't affect on it - I still cannot reproduce. Could you, though, post a DirectEvent's response which renders the partial view with DateFieldFor? In particular, I am mostly interested in a DateField configuration script.

    Also I've just noticed a trailing dot in the DateField in your screenshot. Do you know where it comes from? Maybe, just accidentally typed?

    P.S. Please disregard my questions if you don't want to spend time on that anymore and you are okay to define this a solution.
    <globalization culture="en-US" />
  3. #13
    Daniil
    Sure I want help as much as its needed, no problem. But before go on deep dive, once again I want to underline that this is happening only on Windows 10. Trailing dot is not accidentally typed, it is a way how Microsoft sees regional settings for Serbia (for the first time). Somehow I have a feeling that this problem comes from that side, as some other programs as well won't work as before. Please see the picture:

    Click image for larger version. 

Name:	win10regsettings.png 
Views:	93 
Size:	11.7 KB 
ID:	24257

    Not only that they put dot at the end of the year, but they also put dot in time (instead of colon, as it was for Serbian regional settings, since windows began). I don't need to mention that of course we don't put trailing dot at the end of the year, and dot between hours minutes and seconds and I simply can't understand why they changed it that way.

    Ok, back to business now.
    Could you, though, post a DirectEvent's response which renders the partial view with DateFieldFor? In particular, I am mostly interested in a DateField configuration script.
    How can I do this?
  4. #14
    Thank you for the details!

    Yes, it looks like that a default MVC DateTime model binder cannot parse a date string from a request. Personally, I am not sure why it happens. Maybe, a culprit is a trailing dot indeed, but I cannot prove it. It might be difficult to prove without a possibility to reproduce it locally.

    Please try to run this non-Ext.NET sample on Windows 10 where the original issue happens.

    Model
    public class Entity
    {
        public DateTime? LaunchDate { get; set; }
    
        public static Entity GetEntitity()
        {
            Entity person = new Entity
            {
                LaunchDate = DateTime.Today
            };
    
            return person;
        }
    }
    View
    @model Work2MVC.Controllers.Entity
    
    <!DOCTYPE html>
    <html>
    <head>
        <title>Ext.Net.MVC v2 Example</title>
    
    </head>
    <body>
        <form action="@Url.Action("Submit")" method="post">
            @Html.EditorFor(m => m.LaunchDate)
    
            <input type="submit" value="Submit">
        </form>
    </body>
    </html>
    Controller
    public ActionResult Index()
    {
        return View(Entity.GetEntitity());
    }
    
    public ActionResult Submit(Entity entity)
    {
        return this.Json(entity.LaunchDate.ToString());
    }
    Please post what you see in a browser after initial page load and after pressing the Submit button.

    For me I see the dates in the format according to my Windows regional settings.

    Could you, though, post a DirectEvent's response which renders the partial view with DateFieldFor? In particular, I am mostly interested in a DateField configuration script.
    How can I do this?
    It is in a request' response. You can inspect requests and their response using a browser's developer tools (usually, a Network tab).
  5. #15
    Daniil
    Somehow i can't reproduce this problem anymore. Even if I remove <globalization culture="en-US" />, it works without problem (your sample works as expected too). I don't know what I have done. I played a bit with regional settings on my computer, but even after I reset all settings it still works. Thank you for support and sorry for wasting your time.
  6. #16
    Glad to hear it is not reproducible anymore. Maybe, some Windows update fixed that? Well, never mind. If the issue re-appear, you could post a follow-up in this thread without starting a new forum thread.
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 0
    Last Post: Mar 14, 2013, 3:37 PM
  2. Replies: 7
    Last Post: Aug 23, 2012, 6:55 AM
  3. [CLOSED] DateField IsEmpty always returns false
    By brettmas in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Sep 23, 2010, 1:29 AM
  4. [CLOSED] #{AjaxMethods} returns null
    By Steve in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 14, 2009, 7:22 AM
  5. [CLOSED] datefield always returns min value
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 30, 2009, 8:22 AM

Tags for this Thread

Posting Permissions