searching a column containing an array of objects
searching a column containing an array of objects
I'm having trouble finding a way to implement this use case, and I'm hoping someone here can point me in the right direction.
Suppose you want to display a datatable of family members to plan a reunion. The columns might be things like ID, First Name, Last Name, Address, RSVP'd, etc. If one of your family members has more than one address, then the Address column is actually an array of objects, each object being one address. Now each Address object would have a property for parking spaces. The issue I'm having is this: if you wanted to determine the best place to have the reunion, say by looking at who has the most parking available, you would search that column for addresses with 10 parking spaces.
To clarify, here is an example of one row in the table:
{
id: 1,
firstName: "John",
lastName: "Doe",
address: [
{
city: "Chicago",
state: "Illinois",
parking: 0
}, {
city: "Miami",
state: "Florida",
parking: 2
}
],
rsvp: true
}
In my use case, the Address column would actually be hidden, but what is important is that I can search the column for a property of more than one object in an array.
If this was unclear I would be more than happy to explain myself
Answers
Hi @powerwerker_tb ,
You could store whatever you like in that hidden column, and then create a custom search, either from
columns.render
or a plugin.Cheers,
Colin