how to custom define the search field name

how to custom define the search field name

ihuangmxihuangmx Posts: 26Questions: 9Answers: 1
edited March 2018 in DataTables 1.10

Hi, I got a problem, I defined a field 'good_id' like this

{
            data: 'good_id',
            searchable: false,
            render: function(data, type, row, meta){
                if(row.good){
                    return row.good.name;
                }
                return '';
            }
        },  

but when I search , I want to search the field 'good.name' not 'good_id', so how should I do ?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi ihuangmx,

    Take a look at this example - here there's a different data source being used for the display and the filter.

    For you, you could change the render on line 4 so that you do what you're currently doing for the display, then add a second function for the filter.

    Hope that helps,

    Cheers,

    Colin

This discussion has been closed.