2

I'm planning to use datatables to retrieve all my user data from a mysql table and display them . I'm using their server-side processing code to retrieve all data . I've a requirement where certain additional columns that require custom value to be inserted .

$('#data').dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "userlist.php"
} );

In server side processing,

$aColumns = array('col1', 'col2', 'col3');

Actual columns to be displayed,

<th>col1</th>
<th>col2</th>
<th>col3</th>
<th>col4</th>

where col4 contains an example code like ,

<a href='del.php?userid=col1value></a>

How can i accomplish this ?

Refer : http://datatables.net/examples/server_side/server_side.html

1 Answer 1

2

all you need to do is send the fourth column as HTML tag, and it will work for example while returning the value from serverside

$aColumns = array('col1', 'col2', 'col3', "<a href='del.php?userid=col1value>sometext</a>");

and it will work :).

P.S: you can return anything from server side, it can be HTML tags or a string, datatables will place the value inside of your column without any problem.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi, the array in acolums denote column name in mysql so i think i cannot write html code there.
I ended up uisng mDataProp. Thanks for your help.

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.