ColumnControl - search with different order and search type

ColumnControl - search with different order and search type

spownspown Posts: 21Questions: 8Answers: 0

Link to test case: https://live.datatables.net/gezadipu/12/
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Is there any way to serach priority col as text not number and also order as number?

I found columnDefs like this, but i want to target search in menu, which still act as number

                    columnControl: {
                        target: 1,
                        content: ['searchText']
                    }

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 65,740Questions: 1Answers: 10,934 Site admin
    Answer ✓

    https://live.datatables.net/gezadipu/13/edit

    You'd just missed the columnControl property in the columnDefs object.

    Good point this - I'll see if I can improve the default handling for that.

    Allan

  • spownspown Posts: 21Questions: 8Answers: 0

    @Allan I think I might have found a bug.

    https://live.datatables.net/gezadipu/15/

    Try searching using "Contains" and type "normá".

    The Task column works correctly, but in Priority it returns no results. Or am I missing something?

  • allanallan Posts: 65,740Questions: 1Answers: 10,934 Site admin

    Looks like there be a normalisation error when working with the data attributes. I'll take a look into it.

    Allan

  • spownspown Posts: 21Questions: 8Answers: 0

    Have there been any updates or progress?

  • allanallan Posts: 65,740Questions: 1Answers: 10,934 Site admin

    Thanks for the prompt - I've been working on other aspects and only just circling back to this today.

    I've just been digging into it and the issue is with the combination of data-order and data-search. The issue is that the data type is detected as numeric (due to the order property), so there is no normalisation done on the search value (since it isn't needed for search).

    There are a bunch of options to resolve this:

    1. Use normalised data in data-search
    2. Use something other than numeric data in data-order (a, b, c, etc if you need to define an order).
    3. Assign a normalisation function to the search property for the num type. This can be done with:
    DataTable.type('num', 'search', DataTable.util.diacritics);
    

    Here is an updated example: https://live.datatables.net/gezadipu/16/edit .

    A true fix would see a separation of data types for search, order and display, but that is a major overhaul which I can't do at the moment. Option 3 above might be the best option for you just now I think, as it is one line of extra code and uses the public APIs.

    I'll need to think further on what, if any, changes to make in DataTables as a result of this!

    Allan

Sign In or Register to comment.