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)
            }
    
    评论

报告相同问题?