0

I'm using jQuery DataTable to form a table. Servlet output looks like this:

{
  "iTotalRecords": 11,
  "iTotalDisplayRecords": 11,
  "aaData": [
    {
      "idUser": 1,
      "firstName": "example admin",
      "lastName": "surname",
      "password": "admin",
      "email": "[email protected]",
      "role": "ADMINISTRATOR"
    },
    {
      "idUser": 2,
      "firstName": "user",
      "lastName": "user",
      "password": "user",
      "email": "[email protected]",
      "role": "USER"
    },
...

Information comes from mysql. This is my js code:

<script>
        $(document).ready( function () {
        $('#users').DataTable({
            "bProcessing": true,
            "bServerSide": false,
            "sAjaxSource": "/IssueTracker/main/users",
            "aoColumns": [
                    { "mData": "idUser", "sClass": "center" },
                    { "mData": "firstName", "sClass": "center"},
                    { "mData": "lastName", "sClass": "center" },         
                    { "mData": "email", "sClass": "center"},  
                    { "mData": "role", "sClass": "center" },  
                    { "sClass": "center", 
                        "fnRender": function( oObj ) {
                            return '<a href="' + oObj.aData["idUser"] + '">' + oObj.aData["email"] + '</a>';
                        }   
                    }
            ]
        });
        } )
</script>

I just want to get the actual data, but my jsp don't display links... What is wrong?

1 Answer 1

1

Find answer on my own question. We need to add two new functions fot link column information with type:

{ "mData": function(source) { 
                        var resObj = {
                                'idUser' : source.idUser,
                                'email' : source.email,
                              }
                              return resObj;    
                    },
                    'mRender': function(resObj) {
                        var res = '<a href="url='+ resObj.idUser + '&email=' + resObj.email + '" >text</a>';
                        return res;
                      }
                    }
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.