Automatic row ID addition in datatables (jQuery)

Automatic row ID addition in datatables (jQuery)

dyapasrikanthdyapasrikanth Posts: 20Questions: 0Answers: 0
edited June 2011 in DataTables 1.8
Hi to all i am a java programmer. I can't understand PHP code that what is given as example for ROWID, ROWCLASS. Pls help in order to construct JSON data in java.
What is an expected output format for JSON data in order to send ROWID and ROWCLASS attributes to datatables from java.
This is my output format

{"iTotalRecords":21,
"iTotalDisplayRecords":21,
"aaData":[
[1,"dves","fe323cdf","dfeffwecwe",23,"asdfasf"],
[2,"cew","ewe3cdf","dfeffwecwe",33,"asdfasf"],
[3,"ewf","bv3df","dfeffwecwe",34,"fefwwfdfasf"],
[4,"fwe","ew3cdf","dfeffwecwe",30,"sdfa asdfasf"]
]}
for this one i created an object of this class

public class DTSerializedObject implements java.io.Serializable
{
public int iTotalRecords;
public int iTotalDisplayRecords;
public ArrayList aaData;
}
then i passed that object to flexjson JSONSerializer class to get desired format.

Replies

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin
    This example shows the format required (it's objects, not arrays): http://datatables.net/release-datatables/examples/server_side/ids.html (have a look at the XHR in Firebug).

    Have a look also at this blog which takes about mDataProp which you will need for DT_RowId to work (since you will be working with objects, not arrays): http://datatables.net/blog/Extended_data_source_options_with_DataTables

    Allan
  • dyapasrikanthdyapasrikanth Posts: 20Questions: 0Answers: 0
    edited June 2011
    Thanks allan
    Is JSON output should be like this

    {"iTotalRecords":21,
    "iTotalDisplayRecords":21,
    "aaData":[
    {"DT_RowClass":"special","col1":1,"col2":"dves","col3":"fe323cdf","col4":"dfeffwecwe","col5":23,"col6":"asdfasf"},
    .............
    ]}

    I don't know how to use Firebug to see the XHR
This discussion has been closed.