SearchPane with server-side data
SearchPane with server-side data
Hi Alan, I'm trying to use this for my server-side DT but I'm unable to get the search-pane items/options shown.
- My server-side script returns each row as an array.
- I use columnDefs [{targets: 0, data: 0}, {targets:1, data:1}...] to assign column indexes with data
- dtOptions has searchPanes : { initCollapsed : true, columns : [1] }
- column 1 name == "Type" (type of a certificate) but I don't use this name anywhere as i work with indexes.
Problem
After ajax has returned the rows, searchPane is empty and shows** "No SearchPanes".**
What I have tried
I have tried to assign a field name via columnDefs like
columnDefs [{targets: 0, data: 0, name: 'Id'}, {targets:1, data:1, name: 'Type'}...]
but it didn't help either
****Question: ****
1. Can I work with array data and still use searchPane?
2. Do I need to return object as data row to work with searchPane?
appreciate your work and help.
Returned JSON: (trimmed)
{
"draw": 1,
"recordsTotal": 1323,
"recordsFiltered": 1323,
"data": [
[
"10020",
"Gas Certificate",
"-51",
"08/03/2022",
"address1",
"10020"
],
[
"10021",
"Insurance Certificate",
"-758",
"31/03/2020",
"address2",
"10021"
],
....
[
"10074",
"Gas Certificate",
"-179",
"31/10/2021",
"address3",
"10074"
]
],
"error": null,
"searchPanes": {
"options": {
"Type": [
{
"label": "Gas Certificate",
"total": 2,
"value": "Gas Certificate",
"count": 2
},
{
"label": "Insurance Certificate",
"total": 1,
"value": "Insurance Certificate",
"count": 1
}
]
}
}
}
This question has an accepted answers - jump to answer
Answers
You are on the right track - it is because the options refer to a
Type
data point which isn't configured for a column since, as you note, you are using array data.Change
Type
to be1
and I think it should work (I haven't actually tested that!). That way the option will match the column data points.Allan
Dear Allan, I admired your quick response and sorry that I could not come back sooner. Yes it did work. Thank you.