如何在Kendo UI Grid中对月份进行排序

时间:2015-04-02 12:12:56

标签: javascript jquery kendo-ui

我想在kendo ui grid中对月份(MMM-yyyy)进行排序。但排序是字母表。

示例:当前排序的工作方式如下:

APR-2010 APR-2012 四月,2015年 二月2010 二月-2011 07月2015年 七月-2016

但我想要低于输出:

FEB-2010 APR-2010 二月-2011 APR-2012 四月,2015年 07月2015年 七月-2016

  function loadevent(dataval){
$("#grid").kendoGrid({

    dataSource: {
        type: "json",

      data: dataval,
        schema:{
             data :'sales',
            model: {
                fields: {
                    SBU: { type: "string" },    
                    CLIENT : { type: "string" },
                    REGION : { type: "string" } ,
                    DELIVERY  : { type: "string" } ,
                    PLAN : { type: "number" },
                    POTENTIAL  : { type: "number" },
                    ESTIMATE  : { type: "number" },
                    ACTUAL  : { type: "number" },
                    ACTUALGAP   : { type: "number" },
                    SALESMGN: { type: "string" },
                    MONTHYEAR: { type: "string" },
                    QUARTER: { type: "string" }
                }
            }
        },
        pageSize: 20,
        serverPaging: true,
        group: {

            field: "QUARTER", aggregates: [
              //  { field: "CLIENT", aggregate: "count" },
              { field: "MONTHYEAR", aggregate: "sum" },
                { field: "PLAN", aggregate: "sum" },
                { field: "POTENTIAL", aggregate: "sum" },
                { field: "ESTIMATE", aggregate: "sum" },
                { field: "ACTUAL", aggregate: "sum" },
                { field: "ACTUALGAP", aggregate: "sum" },
                { field: "SALESMGN", aggregate: "count" }
            ]
        }, 

        aggregate: [
          //  { field: "CLIENT", aggregate: "count" },
          { field: "QUARTER", aggregate: "sum" },
            { field: "PLAN", aggregate: "sum" },
            { field: "POTENTIAL", aggregate: "sum" },
            { field: "ESTIMATE", aggregate: "sum" },
            { field: "ACTUAL", aggregate: "sum" },
            { field: "ACTUALGAP", aggregate: "sum" },
           { field: "SBU", aggregate: "count" }
          //  { field: "UnitsInStock", aggregate: "max" }
        ]  
    },
   //height : '100%',
    sortable: true,
    //pageable: true,
    groupable: true,
    filterable: true,
    columnMenu: true,
    reorderable: true,
   resizable: true,
   scrollable: true,
   height    : gridheight,
    columns: [
      //  { width: 300, field: "CLIENT", title: "Client", aggregates: ["count"], footerTemplate: "Total Count: #=count#", groupFooterTemplate: "Count: #=count#" },
        { width: 100, field: "CLIENT", title: "Client" },
        { width: 100, field: "REGION", title: "Region"},
        { width: 100, field: "DELIVERY", title: "Delivery"},
        //{ width: 300, field: "PLAN", title: "Plan" aggregates: ["sum"] },
        //{ width: 300, field: "POTENTIAL", title: "Potential" aggregates: ["sum"] },
        //{ width: 300, field: "ESTIMATE", title: "Estimate", aggregates: ["sum"] },
       // { width: 300, field: "ACTUAL", title: "Actual", aggregates: ["sum"] },
       // { width: 300, field: "ACTUALGAP", title: "Actual Vs Plan Gap", aggregates: ["sum"] },   
       { width: 100, field: "QUARTER", title: "Quarterly" },
       { width: 100, field: "PLAN", title: "Plan" ,aggregates: ["sum"],template: '<div style="text-align:right;">#= kendo.format("{0:n0}",PLAN) #</div>',groupFooterTemplate: '<div style="text-align:right;">#= kendo.format("{0:n0}",sum) #',footerTemplate: '<div style="text-align:right;">#= kendo.format("{0:n0}",sum) #'},
       { width: 100, field: "POTENTIAL", title: "Potential" ,aggregates: ["sum"],template: '<div style="text-align:right;">#= kendo.format("{0:n0}",POTENTIAL) #</div>',groupFooterTemplate: '<div style="text-align:right;">#= kendo.format("{0:n0}",sum) #',footerTemplate: '<div style="text-align:right;">#= kendo.format("{0:n0}",sum) #'},
       { width: 100, field: "ESTIMATE", title: "Estimate", aggregates: ["sum"] ,template: '<div style="text-align:right;">#= kendo.format("{0:n0}",ESTIMATE) #</div>',groupFooterTemplate: '<div style="text-align:right;">#= kendo.format("{0:n0}",sum) #',footerTemplate: '<div style="text-align:right;">#= kendo.format("{0:n0}",sum) #'},
       { width: 100, field: "ACTUAL", title: "Actual", aggregates: ["sum"],template: '<div style="text-align:right;">#= kendo.format("{0:n0}",ACTUAL) #</div>',groupFooterTemplate: '<div style="text-align:right;">#= kendo.format("{0:n0}",sum) #' ,footerTemplate: '<div style="text-align:right;">#= kendo.format("{0:n0}",sum) #'},
       { width: 100, field: "ACTUALGAP", title: "Actual Vs Plan Gap", aggregates: ["sum"] ,template: '<div style="text-align:right;">#= kendo.format("{0:n0}",ACTUALGAP) #</div>',groupFooterTemplate: '<div style="text-align:right;">#= kendo.format("{0:n0}",sum) #',footerTemplate:'<div style="text-align:right;">#= kendo.format("{0:n0}",sum) #' },
       { width: 100, field: "MONTHYEAR", title: "Month-Year" }
        // { width: 100, field: "ACTUALGAP", title: "Actual Vs Plan Gap", aggregates: ["sum"] ,footerTemplate: '#= kendo.toString(sum, "##,#") #'},


     //{ width: 300, field: "SBU", title: "SBU", groupHeaderTemplate: "SBU: #= value # (Count: #= count#)" }
    ]
});
}

0 个答案:

没有答案