DataTable Search Doesnot work
DataTable Search Doesnot work
anim_95
Posts: 6Questions: 2Answers: 0
Datatable Search doesnot work when td value is <td><input type="text"/></td>. Please tell me what is the solution
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Thanks for your question. As noted in the forum rules, please post a link to a running test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
http://live.datatables.net/qujewege/1/edit
this is the live link here search does not work
Thanks for the live link. DataTables is intended to be used with read-only data, and Editor if that data is to be edited. I may be missing something, but why would you want those table cells to be input types on a DataTable?
Cheers,
Colin
As per the requirement from the mentor I have to use textboxs in table. Is there any solution for this problem?
It's not a problem as such, since it's not being used in the way intended. If the intention is to get the styling of an input box, you could just style those TD elements with some CSS.
Not at this time sorry. Ordering does have that ability, but not yet for search.
Allan
In addition to the ordering link Allan provided you can use
columns.render
to get the.val()
of the input and return that for thefilter
operation. In order for this to work you will need an event handler to update thevalue
attribute of the input and to usecell().invalidate()
, along withdraw()
, to have Datatables update it's cache and re-sort the table.Something like this for the render function:
Kevin
Thanks kthorngren this works absolutely fine for me
For prosperity, I was playing around with Kevin's suggestion, here it is:
http://live.datatables.net/yecayovo/3/edit
There are a couple things needed for the example to completely work. The 'input' ordering needs setup as described in the example Allan pointed to. Also for the filtering to work the input value attribute needs to be updated for the render function to have the correct value.
Updated example:
http://live.datatables.net/yupezaci/1/edit
Kevin
Gotcha, I didn't understand why the invalidate was needed, but yep, that's when you change the cell data! I get there, slowly