Modifying Datatables SearchPane to filter on form fields

Modifying Datatables SearchPane to filter on form fields

avinash2javinash2j Posts: 2Questions: 1Answers: 0

I have a table with form fields. That is, input textboxes, drop down menus etc. I would like to modify the SEARCH PANE feature
(see here: https://datatables.net/blog/2017-11-30) so that it will allow me to filter on the form fields.

I trying to modify the source code which would allow me to do so. However, I don't know which lines in the source code to modify. Can you please assist me?

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583
    edited March 2019

    Hi @avinash2j ,

    That's likely to be a fairly large job. SearchPane scans the table data at initialisation so that it can create the options. If you've got cells that can be changed (input controls and drop downs), those assumptions on what to display will be broken. You'll have to rescan on every change event on those controls and recreate SearchPane. Not impossible, but certainly more than a trivial task.

    Cheers,

    Colin

  • avinash2javinash2j Posts: 2Questions: 1Answers: 0

    Hi @colin ,

    The drop down menus are static and would not change .

    My new approach is to build a widget which would be interoperable with the data tables source code.This is the function which I am trying to modify in order to build a widget which would enable me to get the search pane to work as desired.

    this.fnGetPosition = function( node )
        {
            var api = this.api( true );
            var nodeName = node.nodeName.toUpperCase();
    
            if ( nodeName == 'TR' ) {
                return api.row( node ).index();
            }
            else if ( nodeName == 'TD' || nodeName == 'TH' ) {
                var cell = api.cell( node ).index();
    
                return [
                    cell.row,
                    cell.columnVisible,
                    cell.column
                ];
            }
            return null;
        };
    

    Do you have any suggestions about how I can do this?

This discussion has been closed.