Jquery Handsontable Sorting on specific columns

2019-08-07 05:55发布

     **Sorting Issue**

I have a plugin for the handsontable.I am sorting on the column headers,sorting is working fine,but what i needs is the sorting on the specific columns.

Is this possible in handsontable??.I am searching from the whole day.

I have the following code:

 **Code Section Handsontable**

    var $container = $("#grid");
    $container.handsontable({
        data:myData,
        startRows:10,
        startCols: 22,
        colWidths: [50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 70, 80, 80, 80],
        width:1380,
        height: 360,
        contextmenu: true,
        rowHeaders: true,
        manualColumnResize: true,
        manualColumnMove: true,
        colHeaders: ["Bold", "Empty", "LN", "Cust", "Leas", "Sub<br/>Cust", "Sub <br/>Leas", "EMC", "Sub <br/>CSO<br/>S", "FA<br/>LN",
        "M", "Non-<br/>Rev", "S Ops<br/>ID", "Sales", "Imp Dir", "Imp Date", "IC", "Mod", "Eng", "Cont-<br/>Date", "Current<br/>Eff",
        "Current<br/>CSOS"],

        columns: [{ data: 0, readOnly: true }, { data: 1, readOnly: true }, { data: 2 }, { data: 3 }, { data: 4 }, { data: 5 }, { data: 6 }, { data: 7 }, { data: 8 }
             , { data: 9 }, { data: 10 }, { data: 11 }, { data: 12 }, { data: 13 }, { data: 14 }, { data:15 }, { data: 16 }, { data: 17 }, { data: 18 }
             , { data: 19 }, { data: 20 }, {data:21}],
        columnSorting: true,
    });

I have set column sorting to true,can it be done on specific columns. I dont want to sort column sales. If user will click on it i don't want to sort the data. Any suggestions on how to make this work or an other direction to get the job done would be appreciated.

2条回答
萌系小妹纸
2楼-- · 2019-08-07 06:04

To sort by the fifth column descending

columnSorting: {
    column: 4,
    sortOrder: true


},
查看更多
你好瞎i
3楼-- · 2019-08-07 06:12

It is very strange solution, but it worked for me. Handsontable somehow does not react on sorting when you put your header text inside a tag, e.g. <span>. So I suggest to you to define the "Sales" header in colHeaders: section as:

"<span>Sales</span>"

Strange, but it works.

查看更多
登录 后发表回答