Dilemma in HTML colums and serverside processing
Dilemma in HTML colums and serverside processing
bozden
Posts: 10Questions: 0Answers: 0
Hi,
I started to use Ajax on all my DTs, using a slightly modified version of your SQL example. The problem is I want to use the last column of every table for HTML/JS driven buttons. For 3 database columns I use 4 TD's in DT HTML. On the other hand the PHP file returns a JSON for 3 colums, which causes the famous error as one column is missing:
[code]DataTables warning (table id = 'mytable'): Requested unknown parameter '3' from the data source for row 0[/code]
The JSON code is:
[code]{
"sEcho":1,
"iTotalRecords":"1",
"iTotalDisplayRecords":"1",
"aaData":[
[
"1",
"Ana Bina",
"Ana m\u00fcze binas\u0131"
]
]
}
[/code]
To correct this error one solution is to add a blank for the missing column in JSON. To do that I changed the last part of PHP code to this:
[code]
while ( $aRow = mysqli_fetch_array( $rResult ) ) {
$row = array();
for ( $i=0 ; $i
I started to use Ajax on all my DTs, using a slightly modified version of your SQL example. The problem is I want to use the last column of every table for HTML/JS driven buttons. For 3 database columns I use 4 TD's in DT HTML. On the other hand the PHP file returns a JSON for 3 colums, which causes the famous error as one column is missing:
[code]DataTables warning (table id = 'mytable'): Requested unknown parameter '3' from the data source for row 0[/code]
The JSON code is:
[code]{
"sEcho":1,
"iTotalRecords":"1",
"iTotalDisplayRecords":"1",
"aaData":[
[
"1",
"Ana Bina",
"Ana m\u00fcze binas\u0131"
]
]
}
[/code]
To correct this error one solution is to add a blank for the missing column in JSON. To do that I changed the last part of PHP code to this:
[code]
while ( $aRow = mysqli_fetch_array( $rResult ) ) {
$row = array();
for ( $i=0 ; $i
This discussion has been closed.
Replies
The only problem with this approach is that the Ajax call now returns more data and thus slows the rendering.
Allan
[code]
mData: null,
mRender: function ( data, type, row ) {
return row.id;
}
[/code]
Assuming the primary key is an object property called `id` .
Allan