0

Here is my code

oTable = $('#userlisttable')
                            .dataTable(
                                    {
                                        "serverSide" : false,
                                        "ajax" : {
                                            "url" : context + "user/get",
                                        },
                                        "columns" : [ {
                                            "data" : "username"
                                        }, {
                                            "data" : "userpassword"
                                        }, {
                                            "data" : "usertype"
                                        }, {
                                            "data" : "firstname"
                                        }, {
                                            "data" : "lastname"
                                        }, {
                                            "data" : "emailaddress"
                                        }, {
                                            "data" : "isactive"
                                        }, ],


                                        "columnDefs" : [ {
                                            "targets" : "7",
                                            "data" : "userId",
                                            "render" : function(data, type,
                                                    full, meta) {
                                                return '<a href="#" id="row'
                                                        + data
                                                        + '" class="btn btn-success" onclick="callModal(id)"><i class="glyphicon glyphicon-edit icon-white"></i>EDIT</a> &nbsp;&nbsp;<a href="#" id="row'
                                                        + data
                                                        + '" class="btn btn-danger" onclick="callDeleteModal(id)"><i class="glyphicon glyphicon-trash icon-white"></i>Deactivate</a>';
                                            }
                                        } ],

                                        "sDom" : 'T<"clear">lfrtip',
                                        "oTableTools" : {
                                            "sRowSelect" : "single",
                                            "sSwfPath" : "../../resources/swf/copy_csv_xls_pdf.swf",
                                              "aButtons": [
                                                            "csv" 
                                                        ]
                                        }

                                    });

server returns following Json

[{"password":"password","username":"user","lastAccess":1408089626000,"creationDate":1408089626000,"userId":1,"lastName":"reddy","isActive":"y","firstName":"manjari","email":"[email protected]","isLdap":"y","ldapQuery":"query","accessType":"any","usertype":"admin"}]

but data is not dislpled in datatable.

1 Answer 1

1

From the doc on the ajax option (scroll down to the examples) :

Get JSON data from a file via Ajax, using dataSrc to read data from a plain array rather than an array in an object:

$('#example').dataTable( {
  "ajax": {
    "url": "data.json",
    "dataSrc": ""   
   } 
} );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.