ColumnControl searchList when cell data is an array.
ColumnControl searchList when cell data is an array.
I have a Datatable with columns containing array data ["option1", "option2" "option3"].
The column is created with these options:
{
data: "example_column",
name: "example_column",
render: (data: any, type: any) => {
if (type === "display") {
return `<div class="mount-col" data-value='${JSON.stringify(data)}'></div>`;
}
return data;
}
(This is for a Vue project, and I am mounting custom tag components to the rendered div using createdRow. That is why display is rendering empty divs)
{
targets: ["example_column:name"],
columnControl: [
[{
extend: "searchList",
orthogonal: "searchList"
}]
]
}
This results in the searchList's filter options to consist of the arrays joined as a single string for each row "option1,option2,option3"
Ideally I would want each array element to be a selectable option, and it would filter the rows to only ones with arrays that contain the selected options.
Is this possible at all?
Here's an example table https://live.datatables.net/coratibu/2/edit
Replies
Currently no, I'm afraid this isn't possible in ColumnControl. It is something that I plan to add in a future version. SearchPanes does have array capability already, but ColumnControl does not yet. Sorry.
Allan
Hi,
Following up on this topic, we have the same need in our app.
When a cell contains multiple values (e.g. "Opt1, Opt2, Opt3.."), the searchList treats it as a single entry instead of splitting it into individual filterable options.
Is this something that is planned or currently achievable? If not, could you point us to where the searchList values are built in the columnControl source and it’s possible for us to do something on our side?
Thanks!
It is not something that I plan to work on in the immediate future, but it is a feature that could be sponsored. At the moment I'm working on DataTables 3 and updating all of the extensions to be able to work without jQuery (hopefully a beta soon). Once that is done I'll be circling back to new features such as this.
Allan