Why "searchable: false" erase the data of the column?

Why "searchable: false" erase the data of the column?

markzzzmarkzzz Posts: 49Questions: 8Answers: 1

Hi there,

I've this column settings:

columns: [
    ...
    { data: "ClinicID", title: "", visible: false, searchable: true },
    ...
]

I hidden the field, and I want to keep the value within it (because I use as pivot for other searches; i.e. its related to other data).
But:

  • if I set searchable: true and I insert the ID, it filters also for that column on a Search input field (for example).
  • if I set searchable: false, it empty the value, so I can't use it as pivot anymore.

What should I do?
Thanks

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,740Questions: 1Answers: 10,111 Site admin

    Setting the column's searchable flag to false certainly shouldn't make the content invisible. Can you link to a page showing the issue please?

    Allan

  • markzzzmarkzzz Posts: 49Questions: 8Answers: 1
    edited June 2018

    :smile:

    I mean: setting searchable flag to false will prevent to be searched by Search input field.
    But later, if I do somethings like this:

    function SetDataTableCustomFilter(target, columnID) {
        return $.fn.dataTable.ext.search.push(
            function (settings, data, dataIndex) {
                var selectedValue = parseInt($(target).val());
                var dataValue = parseInt(data[columnID]) || 0;
    
                if (isNaN(selectedValue) || dataValue == selectedValue) {
                    return true;
                }
    
                return false;
            }
        );
    }
    

    The field data[columnID] data is always 0 for the columnID with searchable: false, that's what I mean. I need to set searchable: true (so it keep its value), but at that point it returns searcheable by Search input field :neutral:

  • allanallan Posts: 61,740Questions: 1Answers: 10,111 Site admin

    Ah - I see what you mean. The search plug-ins actually get passed more parameters, including the original data object for the column (4th parameter) which you could get the data from.

    Allan

  • markzzzmarkzzz Posts: 49Questions: 8Answers: 1
    edited June 2018

    I see. That's perfect.
    Unfortunately, searchData is "an array" (so I can access with [], and index).
    rowData is an object, and I can't access to it using index/columnid :neutral:

    Is there any workaround?
    Thanks

  • allanallan Posts: 61,740Questions: 1Answers: 10,111 Site admin
    Answer ✓

    The rowData is the original data object for what you use to populate the row. If that is an object, then yes, it would be an object. You could use $.map to convert it to be an array if you need.

    Allan

This discussion has been closed.