bootstrap-table
bootstrap-table copied to clipboard
Searching nested array values possible?
Description
I've searched for other support questions but couldn't find anything related, so maybe this is not tried yet.
I have json file with a structure like:
[
{
"id": "1",
"name": "Foo",
"country": {
"iso": "UK"
},
"seasons": [
{
"year": 2013
},
{
"year": 2016
},
{
"year": 2017
}
]
}
]
When setting up a BT I can use the nested country.iso
field like data-field="country.iso"
so nested fields work.
I'm wondering if it's also possible to do something similar with array fields?
In above case to use the seasons[].year
, for both displaying and searching.
I've written a custom formatter (it's more than just outputting the year) and that works, but I cannot get the search working unfortunately.
The attached example contains a full setup.
Example(s)
https://live.bootstrap-table.com/code/marceloverdijk/12857
You have to write your own search logic using the customSearch option.
Example: https://live.bootstrap-table.com/code/UtechtDustin/12867
Yes I thought so , thx for confirming.
The (negative) side effect of a customSearch is that you have to implement this custom search for the full row.
In this case I would only want a custom search for 1 particular field,
and use BT built-in search capabilities for the other columns automatically like data-searchable
.
The table customSearch
option is quite brutal in terms of what you give away.
Would it be possible to have a customSearch
option on column level, that would eg just return true/false if the search matches that column?
That could be a great feature.
I think we should change the title of this issue to something like "add customSearch method on column level"