Merge 2 Columns into one

Merge 2 Columns into one

EuronetEuronet Posts: 2Questions: 1Answers: 0

Hello everyone. I have already read your discussions on this topic. But my problem is that I already use columnDefs to be able to search only on the first column. When I add this code, which I found in one of your discussions: "(columnDefs: [ { render: function (data, type, row) {return data + ' (' + row[3] + ')'; }, targets: 1}, { visible: false, targets: [3] }]" unfortunately it gives me an error. The two columns are merged into one column, but it no longer carries out the search only on the first column, because columnDefs is used twice for different reasons How can I solve the problem? The table is created by reading a csv file and the columns that form the table are directly the data that come from the csv file. I attach the script I use. Thanks

Answers

  • kthorngrenkthorngren Posts: 21,324Questions: 26Answers: 4,949
    edited October 2023

    columnDefs is an array of definitions. Combine them into one columnDefs option. Something like this:

    columnDefs: [{ targets: [1,2,3,4,5],
                searchable: false,
                },
                { render: function (data, type, row) {
                    return data + ' (' + row[3] + ')'; 
                  }, 
                  targets: 1
                }, 
                { visible: false, targets: [3] }
    ],
    

    Kevin

  • EuronetEuronet Posts: 2Questions: 1Answers: 0

    Ok thanks, your advice worked.

Sign In or Register to comment.