2017-04-17 99 views
0

早上好。我正在使用JqGrid.js文件,我注意到當我嘗試對包含這種格式的數據的列進行排序時(mm/dd/yyyy)它不考慮年份。 sortType始終是「文本」。任何幫助表示讚賞。JQ Grid 4.6不按月份排序日期和年份

addLocalData = function() { 
      var st = ts.p.multiSort ? [] : "", sto=[], fndsort=false, cmtypes={}, grtypes=[], grindexes=[], srcformat, sorttype, newformat; 
      if(!$.isArray(ts.p.data)) { 
       return; 
      } 
      var grpview = ts.p.grouping ? ts.p.groupingView : false, lengrp, gin; 
      $.each(ts.p.colModel,function(){ 
       sorttype = this.sorttype || "text"; 
       if(sorttype === "date" || sorttype === "datetime") { 
        if(this.formatter && typeof this.formatter === 'string' && this.formatter === 'date') { 
         if(this.formatoptions && this.formatoptions.srcformat) { 
          srcformat = this.formatoptions.srcformat; 
         } else { 
          srcformat = $.jgrid.formatter.date.srcformat; 
         } 
         if(this.formatoptions && this.formatoptions.newformat) { 
          newformat = this.formatoptions.newformat; 
         } else { 
          newformat = $.jgrid.formatter.date.newformat; 
         } 
        } else { 
         srcformat = newformat = this.datefmt || "Y-m-d"; 
        } 
        cmtypes[this.name] = {"stype": sorttype, "srcfmt": srcformat,"newfmt":newformat, "sfunc": this.sortfunc || null}; 
       } else { 
        cmtypes[this.name] = {"stype": sorttype, "srcfmt":'',"newfmt":'', "sfunc": this.sortfunc || null}; 
       } 

回答

0

我對代碼做了如下修改。

srcformat = newformat = this.datefmt || "m-d-Y";