Add links

Add links

LArmstrong85LArmstrong85 Posts: 21Questions: 14Answers: 0

Hello,
is it possible to add links in determinate column of datatable?
How I can do it?

Thank you very much

Answers

  • humbughumbug Posts: 9Questions: 1Answers: 0
    edited January 2015

    If you mean into a cell of the table then yes it's possible. when you build your json array just add the relevant html to the field so for instance i did..

    $row_array['destination_station'] = " [" . $target_station . "]<a class='station'  href='.............'>Station Info</a>";
    
    
  • LArmstrong85LArmstrong85 Posts: 21Questions: 14Answers: 0

    Ah you suggest to do it directly in Json... Can you give me an example here?
    http://live.datatables.net/qisogeje/4/edit

    Isn't possible to do it after with Jquery?

  • humbughumbug Posts: 9Questions: 1Answers: 0
    edited January 2015

    i cant really show you on that link as there isn't a place for json however this is a cut down version of what i have to respond to the ajax request from DataTables.

    $row_array['destination_station'] = " [" . $target_station . "]<a class='station'  href='.............'>Station Info</a>";
    
     array_push($return_arr,$row_array);  
    
          // Prepare the response for DataTables
    
        $response = json_encode(array(
            'draw' => intval($_GET['draw']),
            'iTotalRecords' => intval($number_of_stations),
            'iTotalDisplayRecords' => intval($number_of_stations),
            'aaData' => $return_arr
        ));
        echo $response;
    

    I'm not a programmer or anything so I'm still learning myself through a lot of trial and error :) I have no idea if it's possible to do it in Jquery sorry.

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    You can also use columns.render if you don't want to embed it into the JSON. There is an example on that page.

    Allan

This discussion has been closed.