jQWidgets Forums

jQuery UI Widgets Forums Grid Formating Date from JSON result

This topic contains 2 replies, has 2 voices, and was last updated by  MatthewV 9 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Formating Date from JSON result #81741

    MatthewV
    Participant

    I have looked over a few posts here as well as the Cell Formatting documentation but no matter what I do my date always displays as “/Date(14561172000000)/” and I don’t know how to make it into a readable date/time. Where am I going wrong?

    <script type="text/javascript">
            $(document).ready(function ()
            {
                var Source =
                    {
                        datatype: "json",
                        datafields: [
                            { name: "ApprovalStatus", datatype: "string" },
                            { name: "ApprovedBy", datatype: "string" },
                            { name: "AssignedTo", datatype: "string" },
                            { name: "CurrentStatus", datatype: "string" },
                            { name: "DateApproved", datatype: "date" },
                            { name: "DateCompleated", datatype: "date" },
                            { name: "DateStarted", datatype: "date" },
                            { name: "EstimatedEndDate", datatype: "date" },
                            { name: "EstimatedStartDate", datatype: "date" },
                            { name: "ID", datatype: "int" },
                            { name: "Impact", datatype: "string" },
                            { name: "Name", datatype: "string" },
                            { name: "Priority", datatype: "string" },
                            { name: "Reason", datatype: "string" },
                            { name: "Type", datatype: "string" }
                        ],
                        url: '@Url.RouteUrl("GetChangeOrders")'
                    };
    
                var dataAdapter = new $.jqx.dataAdapter(Source);
    
                var RenderNotesPage = function (ID)
                {
                    return '<input type="button" class="gridButton" value="View Notes" onclick="window.open(\'' + '@Url.RouteUrl("ChangeOrderNotes", new { ChangeOrderID = -1 })'.replace("-1", ID) + '\', \'\', \'toolbars=0,width=400,height=400,left=200,top=200,scrollbars=1,resizable=1\'), event.preventDefault();" />';
                }
    
                $("#jqxgrid").jqxGrid(
                    {
                        width: "100%",
                        source: dataAdapter,
                        pageable: true,
                        ready: function ()
                        {
                            var button = $('<input type="button" value="Add New Change Order" id="myButton" />');
                            button.click(function ()
                            {
                                location.href = '@Url.RouteUrl("AddChangeOrder")'
                            });
                            $(".jqx-grid-pager > div:first").append(button);
                        },
                        columns: [
                            { text: "Change Order", datafield: "Name" },
                            { text: "Notes", datafield: "ID", cellsrenderer: RenderNotesPage },
                            { text: "Change Type", datafield: "Type" },
                            { text: "Priority", datafield: "Priority" },
                            { text: "Impact", datafield: "Impact" },
                            { text: "Assigned To", datafield: "AssignedTo" },
                            { text: "Estimated Start Date", datafield: "EstimatedStartDate", cellsformat: 'F' },
                            { text: "Estimated End Date", datafield: "EstimatedEndDate", cellsformat: "dddd, MMMM dd, yyyy h:mm tt" },
                            { text: "Date Started", datafield: "DateStarted", cellsformat: "dddd, MMMM dd, yyyy h:mm tt" },
                            { text: "Date Compleated", datafield: "DateCompleated", cellsformat: "dddd, MMMM dd, yyyy h:mm tt" },
                            { text: "Reason for Change", datafield: "Reason" },
                            { text: "Approval Status", datafield: "ApprovalStatus" },
                            { text: "Approved By", datafield: "ApprovedBy" }
                        ]
                    });
            });
        </script>
    Formating Date from JSON result #81762

    ivailo
    Participant

    Hi MatthewV,

    Use type: "date" instead datatype: "date" , type: "int" instead datatype:datent" and type: "string" instead datatype: "string".

    Best Regards,
    Ivailo Ivanov

    jQWidgets Team
    http://www.jqwidgets.com

    Formating Date from JSON result #81779

    MatthewV
    Participant

    Hi Ivailo,
    Thank you this worked.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.