【问题标题】:Set date to tbd if it is a specific date如果日期是特定日期,则将日期设置为 tbd
【发布时间】:2016-07-25 14:12:16
【问题描述】:

我尝试在网站上四处查看,看看以前是否有人问过这个问题,但我似乎找不到任何关于它的信息。所以我正在使用 mvc 并有一个控制器页面,该页面从 sqlserver 数据库中读取数据,以在包含 jqgrid 的视图中显示它们。

我的问题是如何获取特定的日期时间值“1900-01-01 00:00:00.00”并将其显示为待定?

这是我的两个日期时间列的代码:

schedule.EstimatedQAStartDate = (!reader.IsDBNull(4)) ? reader.GetDateTime(4) : (DateTime?)null; 
schedule.EstimatedorProjectedReleaseDate = (!reader.IsDBNull(5)) ? reader.GetDateTime(5) : (DateTime?)null;

【问题讨论】:

    标签: c# asp.net-mvc datetime jqgrid


    【解决方案1】:

    jqGrid 对此的解决方案是为日期列设置一个格式化程序,如下所示

    这也是我为您创建的jsfiddle 示例。

    function formatDate(cellValue, options, rowObject) {
            if(cellValue=="1900-01-01 00:00:00.00")
                   return "tbd";
                   else
                   return cellValue;
                };
    
                "use strict";
                var mydata = [
                        {id:"1", DocGroupName: "2", Date: "1900-01-01 00:00:00.00", Mandatory: "Yes"},
                        {id:"2", DocGroupName: "6", Date: "2005-03-02 05:00:00.00", Mandatory: "No"},
                        {id:"3", DocGroupName: "6", Date: "2016-08-05 08:40:00.00", Mandatory: "No"},
                    ];
                $("#list").jqGrid({
    
    
                    //url:'php.scripts/customers.get.php',
                    //datatype: 'xml',
                    //mtype: 'POST',
                    datatype: "local",
                    data: mydata,
                    height: "auto",
    
                    colModel :[
                        {name:'id', index:'id', width:55},
                        {name:'DocGroupName',  width:90},
                        {name:'Date', formatter:formatDate, width:90, editable: true },
                        {name:'Mandatory', index:'Mandatory', width:90, editable: true}
    
                    ],
                    pager: '#pager',
                    rowNum:10,
                    rowList:[10,20,30],
                    sortname: 'idcustomers',
                    sortorder: 'asc',
                    viewrecords: true,
                    gridview: true,
                    caption: 'Customers',
                    cellEdit: true,
                    cellsubmit: 'clientArray',
                    afterSaveCell: function(rowid,name,val,iRow,iCol) {
                        if(name=='DocGroupName')
                      {
                      var row = $('#list').jqGrid('getRowData',currentRow);     
                       row.DocList='';
                       var row = $('#list').jqGrid('setRowData',currentRow,row);       
                       }
                    },
                    beforeSaveCell: function(rowid,name,val,iRow,iCol) {
                     // var row = $("#list").getRowData(rowid);
                       var row = $('#list').jqGrid('getRowData',rowid);
                       currentRow= rowid;
    
                    },
    
                });
    

    【讨论】:

      猜你喜欢
      • 2015-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-08
      相关资源
      最近更新 更多