Can datatables sort a column with an input field?

前端 未结 6 1488
囚心锁ツ
囚心锁ツ 2021-01-12 17:41

I am trying to make datatables sort my columns. The first column works okay as it\'s a simple number. However the next column is an input field. When I try to make that sort

6条回答
  •  情深已故
    2021-01-12 18:25

    If you decide to use the columns option where you are rending information from a JSON file you can easily add a hidden span on your render property. It appears as though DataTables looks for text to order and if it cannot find any, it will break. The example at https://datatables.net/examples/plug-ins/dom_sort.html uses a table that has already been rendered. Here is an example using an API:

    ...columns([{ 
            "data": "receivedDate",
            "render": function (data, type, row, meta)
            {
    
                if (data == "null")
                {
                    return "

提交回复
热议问题