DataTable filtering in column with select-list data
DataTable filtering in column with select-list data
rogero
Posts: 2Questions: 0Answers: 0
Hi,
In http://live.datatables.net/mobedan/56/edit I Have:
HTML:
<body>
<div class="container">
<table id="example" class="display" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
<tbody>
<tr>
<td><select name="[0].idInvitadoEstado" class="noduplicate" data-val="true" data-val-number="El campo Estado debe ser un número." data-val-required="El campo Estado es obligatorio."><option selected="selected" value="2">APROBADO</option><option value="3">NO APROBADO</option><option value="4">PENDIENTE CONFIRMACIÓN</option></select></td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$3,120</td>
</tr>
<tr>
<td><select name="[1].idInvitadoEstado" class="noduplicate" data-val="true" data-val-number="El campo Estado debe ser un número." data-val-required="El campo Estado es obligatorio."><option selected="selected" value="2">APROBADO</option><option value="3">NO APROBADO</option><option value="4">PENDIENTE CONFIRMACIÓN</option></select></td>
<td>Director</td>
<td>Edinburgh</td>
<td>63</td>
<td>2011/07/25</td>
<td>$5,300</td>
</tr>
<tr>
<td><select name="[2].idInvitadoEstado" class="noduplicate" data-val="true" data-val-number="El campo Estado debe ser un número." data-val-required="El campo Estado es obligatorio."><option selected="selected" value="2">APROBADO</option><option value="3">NO APROBADO</option><option value="4">PENDIENTE CONFIRMACIÓN</option></select></td>
<td>Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009/01/12</td>
<td>$4,800</td>
</tr>
<tr>
<td><select name="[3].idInvitadoEstado" class="noduplicate" data-val="true" data-val-number="El campo Estado debe ser un número." data-val-required="El campo Estado es obligatorio."><option selected="selected" value="1">PENDIENTE APROBACIÓN</option><option value="2">APROBADO</option><option value="3">NO APROBADO</option></select></td>
<td>Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012/03/29</td>
<td>$3,600</td>
</tr>
<tr>
<td><select name="[4].idInvitadoEstado" class="noduplicate" data-val="true" data-val-number="El campo Estado debe ser un número." data-val-required="El campo Estado es obligatorio."><option selected="selected" value="1">PENDIENTE APROBACIÓN</option><option value="2">APROBADO</option><option value="3">NO APROBADO</option></select></td>
<td>Financial Controller</td>
<td>Edinburgh</td>
<td>33</td>
<td>2008/11/28</td>
<td>$5,300</td>
</tr>
<tr>
<td><select name="[5].idInvitadoEstado" class="noduplicate" data-val="true" data-val-number="El campo Estado debe ser un número." data-val-required="El campo Estado es obligatorio."><option selected="selected" value="1">PENDIENTE APROBACIÓN</option><option value="2">APROBADO</option><option value="3">NO APROBADO</option></select></td>
<td>Integration Specialist</td>
<td>New York</td>
<td>61</td>
<td>2012/12/02</td>
<td>$4,525</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Can I filtering first column? What is the regular expresion?
I think it's -> '^.+selected="selected" value="' + id + '".+$'
But not run
$(document).ready( function () {
var table = $('#example').DataTable();
table
.column(0)
.search( '^.+selected="selected" value="' + id + '".+$', true, false )
.draw();
} );
id it's the value to filtering...
Any ideas? it's possible?
Thanks very much!!
This discussion has been closed.
Replies
Look at the https://datatables.net/reference/option/columns.render documentation. There are a bunch of ideas you could do.
You could add the following inside the td via the render function
--- or ---
You could utilize this
Now within your change event handler, you will need to reference the td and use https://datatables.net/reference/api/cell().invalidate()
Thank you very much @jr42.gordon , but I think this is not valid because I need this input to allow the user to change the values, and then filter ...
I think it's not possible
Sorry for late response, but I use the first option I gave within my application and it works beautifully.
Here is what my render function looks like
Final HTML looks like
Event Handler looks like
And finally the helper function