Search code examples
jqueryhtmlajaxjquery-jtable

How to display HyperLink Data in JTable column?


I want to display a href to the data received from jtable.

Below is the code snippet.

$('#JarDistHist').jtable({
    title: 'Jar Distribution History',
    paging: true,
    //pageSize: 10,
    sorting: true,
    defaultSorting: 'Date ASC',
    actions: {
        listAction: 'StudentActions.php?action=list&DistId=' + cname + '&fitem=' + fitem + '',


        deleteAction: 'StudentActions.php?action=delete'
    },
    fields: {
        id: {

            key: true,
            create: false,
            edit: false,
            list: false,

        },
        Date: {
            title: ' Date',
            type: 'date',
            displayFormat: 'dd-mm-y',
            width: '40%',
            options: '<a href="JarFillingDetail.php?id">'
        },

Solution

  • Take a look on this link : http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/nancy-and-jtable-formatting-your/

    I think this is what you want.

    Add field display.

    When we configure our fields for jtable we have a display attribute that takes a function and in that function we can do our formatting.

    display: function (data) {
                                return $('<a href="JarFillingDetail.php?id="' + data.Id + '"></a>');
                             }