Getting an "Invalid index value 'value'" when using serverSide: true
Getting an "Invalid index value 'value'" when using serverSide: true
Hello,
I am trying to run the example for server-side process, but it seems I am doing something wrong. Maybe someone is able to put me onto the right track for solving this problem.
Here is my javascript
$(document).ready(function() {
$('#example').dataTable( {
"processing": true,
"serverSide": true,
"ajax": "/action/forumList.do?do=getTopicsJSON",
"columns": [
{ "data": "first_name" },
{ "data": "last_name" },
{ "data": "position" },
{ "data": "office" }
]
} );
} );
When running the page, I get a 500 Internal Error with the message: java.lang.IllegalArgumentException: Invalid index value 'value'. The AJAX request was not be sent.
As soon as I commented out the "serverSide" option (or setting it to false), the table is filled with the data I get via the AJAX request.
The JSON given back is valid:
{
"draw": 1,
"recordsTotal": 3,
"recordsFiltered": 3,
"data":
[
{"first_name":"Airi","last_name":"Satou","position":"1","office":"NY"},
{"first_name":"Airi","last_name":"Satou","position":"2","office":"NY"},
{"first_name":"Airi","last_name":"Satou","position":"3","office":"NY"}
]
}
The definition of the table:
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Extn.</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Extn.</th>
</tr>
</tfoot>
</table>
Using DataTables 1.10.1
Thanks in advance for any help!
Dragon013
Answers
Update:
I was able to get down to the source of this problem. In apache's commons beanutil there is a function which parses expressions in request. When parsing search[value], it parses "value" as int because it expects values written in [] to be integers.
As far as I understand the documentation of using serverside in Datatables, search[value] contains the searchterm where 'value' is the index of the array of search options. (the other index is then regex).
Do I have any chance to do a workaround there ?
Thanks in advance!
Dragon013
Just for documentation, if someone gets into the same problems: the main problem is / was Struts 1.x . Luckily were are switching to Spring. With Spring, everything is fine.