Jquery Handsontable Sorting on specific columns

a 夏天 提交于 2019-12-13 18:04:33

问题


     **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.


回答1:


To sort by the fifth column descending

columnSorting: {
    column: 4,
    sortOrder: true


},



回答2:


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.



来源:https://stackoverflow.com/questions/18761314/jquery-handsontable-sorting-on-specific-columns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!