Modify searchPanes values
Modify searchPanes values
Hi! Thank you for an extremely usefull component.
I am trying to find out if there is a possibility to modify searchPanes values to make them text only, instead of <a> links like in table itself?
I pass data to table from Ajax script. For some columns it sends object data, containing {id, display}. Then it renders as for example:
{
"data": "T_DEAL",
"title": "Сделка",
"width": "55px",
className: 'dt-body-left',
render: function (data) {
return '<a href="/crm/deal/details/' + data.id + '/" target=_blank>' +
data.display + '</a>'
},
searchPanes: {show: true}
},
But these cells get to searchPanes exactly as they are rendered — with <a> tag.
So when I click on any of them in searchPane, I click on the link and get redirected to it, instead of normal behaviour — filtering table data.
I search for whole documentation articles and still couldn't find how to modify elements in searchPanes.
Can you help with that?
This question has an accepted answers - jump to answer
Answers
You can use
columns.searchPanes.orthogonal
to modify the text that's displayed in the SearchPanes - orthogonal data can be used to change the text depending on its use. This example is demonstrating that - for you, you would need to strip the HTML from string to remove the link.Colin
Thanks a lot! It worked for me
Having issues getting this to work. Can you provide a working example of this?
@badijd
Colin did provide an example and docs to how to use Orthogonal data. Maybe you can provide us with specific questions you have. A link to your page or a test case with an example of your data will be very helpful for more specific answers.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
here is my example. Note the link can be different for different values in the position column. In the searchpanes, the position also has the link. I cannot figure out how to show only text. http://live.datatables.net/bihidiha/1/edit
Something like this:
http://live.datatables.net/bihidiha/2/edit
Looks like searchPanes uses the
display
orthogonal data. Basically you need to tell searchPanes to use the original data.Kevin