weixin_33725807 2017-05-14 11:41 采纳率: 0%
浏览 47

花式网格日期类型

I tried to implement a Ajax table but have encountered error when trying to implement 'date' type variable with fancygrid.

  1. When json data return null date to the application (especially after table is refresh when a new record is added)

    index: 'pStartDate',
           title: 'Start Date',
           type: 'date',
           format: {
                 read: 'd/m/Y',
                 write: 'd/m/Y',
                 edit: 'd/m/Y'
           }
    
    {"success":"true","data":[{"id":15,"pReport_id":6,"pTypeOfAssessment":null,"pApplicationName":null,"pStartDate":null,"pEndDate":null,"pApplicationURL":null,"pScope":null,"pStatusOfReview":null}],"totalCount":0}
    

Example: http://jsfiddle.net/t786hyhv/

  1. When json data return with data with date, Entering empty date in the field will cause error to occur. This also newly added record by selecting but not adding new date.

    {"success":"true","data":[{"id":35,"pReport_id":6,"pTypeOfAssessment":null,"pApplicationName":null,"pStartDate":"14/05/2017","pEndDate":"14/05/2017","pApplicationURL":null,"pScope":null,"pStatusOfReview":null}],"totalCount":1}
    

Example: http://jsfiddle.net/0noLomqy/

However these does not affect fancygrid that is implemented with local data. E.g. Data: data, instead of

    data: {
        proxy: {
          api: {
            create: 'URL',
            read: 'URL',
            update: 'URL',
            destroy: 'URL'
          }
        }
      }

Note: To allow jsfiddle myjson to return, will have to first access the myjson link https cert to prevent cross domain error.

  • 写回答

2条回答 默认 最新

  • ℡Wang Yan 2017-05-14 14:26
    关注

    Fixed the error by modifying with the following codes:

    case "date":
        if(a.value != null || a.value.length != 0) {
            var e = a.column.format,
            f = Fancy.Date.parse(a.value, e.read, e.mode);
            d.set(f);
        }
    break;
    
    case "date":
        if (e.format && e.format.read) {
            if(e.editor.getDate().length != 0) {
                var j = e.editor.getDate();
                a = Fancy.Date.format(j, e.format.read, void 0, e.format.mode)
            }
        }
    
    case "date":
        return function(b) {
            if (null === b || 0 === b.length) return "";
                var c = Fancy.Date.parse(b, a.read, a.mode);
                return b = Fancy.Date.format(c, a.write, void 0, a.mode)
            }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 对于这个复杂问题的解释说明
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败