How to search by column when I change field?

How to search by column when I change field?

vanxuan1vanxuan1 Posts: 1Questions: 1Answers: 0

With example data
data = [{
_id: 'xyz',
username: 'username',
email: 'email@xyz.com',
profile: {
first_name: 'Viet',
last_name: 'Luong'
}
}]
When I use this data to display with datatable, I will only show columns and columnDefs
columns : [
{data: "_id", title: "ID", searchable: true},
{data: "username", title: "Username", searchable: true},
{data: "profile", title: "First name", searchable: true},
{data: "profile", title: "Last name", searchable: true},
{data: "email", title: "Email"},
],
columnDefs : [
{
className: "first-name",
targets : [2],
render : function (data) {
if (data && data.hasOwnProperty('first_name')) {
return data['first_name'];
} else
return ; } }, { className: "last-name", targets : [3], render : function (data) { if (data && data.hasOwnProperty('last_name')) { return data['last_name']; } else return;
}
},
]
I want to search column by first name or last name, but it only search by profile, so it will return empty. Plesase help me solve this problem.

This discussion has been closed.