Quantcast
Channel: Free community support — DataTables forums
Viewing all articles
Browse latest Browse all 35270

Unable to link a column using datatables

$
0
0
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Populating JSP</title>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="http://cdn.datatables.net/1.10.0/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="http://cdn.datatables.net/1.10.0/css/jquery.dataTables.css" />
<link rel="stylesheet" href="http://cdn.datatables.net/1.10.2/css/jquery.dataTables.css" />

</head>
<body>
    <table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>id</th>
                <th>salary</th>
            </tr>
        </thead>
        <tbody>

        </tbody>
    </table>

     <script>

        $(document).ready(function() {
                $('#example').dataTable( {
                    serverSide: true,
                    "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
                        $('td:eq(2)', nRow).html('<a href="http://www.google.com' + aData[2] + '">' +
                            aData[2] + '</a>');
                        return nRow;
                    },
                    ajax : {
                        url: 'hello/data1',
                        dataType:'json',
                        type: 'POST'

                    }

                }

                 );
        });

    </script>

</body>
</html>

I have 2 coulmns, ID and Salary. I am linking the salary to google.com, for that I am using fnRowCallback function. But that doesn't seem to work. Where do you think I am going wrong. The jsp is shown above.


Viewing all articles
Browse latest Browse all 35270

Trending Articles