douli7841 2014-04-24 20:13
浏览 119
已采纳

jQuery数据表将日期显示为[object Object]

My code below works fine as far as querying a php web service and displaying the results using jQuery datatable.

The issue is that date values are being returned as [object object].

Any ideas why I am getting these values and how to resolve them?

My code is below:

 <script type="text/javascript" charset="utf-8">
$(document).ready(function() {
    /* Init DataTables */
$("#example").dataTable( {
    "sProcessing" : true,
"sDom":'T<"clear">',
"sJQueryUI": true,
"sPaginationType": "full_numbers",
"sDom": 'T<"clear"><"fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"lfr>t<"fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"ip>',
    "sAjaxSource" : "Requests.php",
    "sAjaxDataProp" : "",
    "sDestroy" : false,
    "sScrollY": "400px",
    "fnServerData" : function(sSource, aoData, fnCallback) {
        request = $.ajax({
            "dataType" : "json",
            "type" : "GET",
            "url" : sSource,
            "data" : aoData,
            "success" : fnCallback
        });
    },
         "aoColumns" : [
{
                        "mDataProp": "RequestID", "sWidth": "50px", sSortable: true,
                        "bSearchable": false,
                        "bSortable": false,
                        "fnRender": function (oObj)
                        {
                            // oObj.aData[0] returns the RequestID
                            return "<a href='details.php?RequestID="
                                + oObj.aData["RequestID"] + "'> " + oObj.aData["RequestID"] + " </a>";
                        }
                       },
          { mDataProp: "RequestDate",  "sWidth": "100px", sSortable: true },
          { mDataProp: "RequestorFullName",  "sWidth": "150px", sSortable: true },
          { mDataProp: "PrimarySiteContactDisplay",  "sWidth": "250px", sSortable: true },
          { mDataProp: "RequestLocation",  "sWidth": "150px", sSortable: true },
          { mDataProp: "RequestDescription",  "sWidth": "200px", sSortable: true },
          { mDataProp: "RequestStatus",  "sWidth": "100px", sSortable: true },

        ],
      })
$('#example tbody tr').click(function () {
    if ($(this).hasClass('selected')) $(this).removeClass('selected');
    else
    {
        $(this).siblings('.selected').removeClass('selected');
        $(this).addClass('selected');
    }
});
   });
</script>


<div id="TableToolsToolbar" class="fg-buttonset ui-helper-clearfix"> </div>
<table><tr><td></td</tr></table>
<table cellpadding="0" cellspacing="0" border="0" style="width:100%;" class="display" id="cityworks">
<thead style="background-color:#DC5807; color:White; font-weight:bold;font-size:10pt;">
<tr style="border:solid 1px #000000">
    <th>ID</th>
    <th>Date</th>
    <th>Requestor</th>
    <th>Site Contact</th>
    <th>Location</th>
    <th>Description</th>
    <th>Status</th>
  </tr>
 </thead>
<tbody>
</tbody>
</table>
</div>
  • 写回答

1条回答 默认 最新

  • dsf323233323332 2014-04-25 13:21
    关注

    I was able to fix it.

    I had to convert date to string on server side to resolve it.

    convert(char(10),aa.[requestdate],101) as RequestDate
    

    Thanks all for your feedbacks.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 c#打开word开启修订并实时显示批注
  • ¥15 如何解决ldsc的这条报错/index error
  • ¥15 VS2022+WDK驱动开发环境
  • ¥30 关于#java#的问题,请各位专家解答!
  • ¥30 vue+element根据数据循环生成多个table,如何实现最后一列 平均分合并
  • ¥20 pcf8563时钟芯片不启振
  • ¥20 pip2.40更新pip2.43时报错
  • ¥15 换yum源但仍然用不了httpd
  • ¥50 C# 使用DEVMOD设置打印机首选项
  • ¥15 麒麟V10 arm安装gdal