URL Links in datatable columns

URL Links in datatable columns

tcleggtclegg Posts: 4Questions: 0Answers: 0
edited July 2010 in General
We currently have a custom made table which involves a large amount of client side code to set up the data that is displayed. We would like to move to using JQuery so that we are not dependant on IE. However the datatables plugin does not seem to provide the ability to have url links embedded within column data. For example if I have a list of flights at an airport I need to have a url link on the flightid column which would take me to another page displaying the flight information. In the same row I could have a count of the number of bags on the flight and I would want a url link which would take me to another page showing the list of bags corresponding to the number. Is this possible using Datatables????

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Can you not just put the whatever HTML into your table? http://datatables.net/examples/advanced_init/html_sort.html

    Allan
  • tcleggtclegg Posts: 4Questions: 0Answers: 0
    Allan,

    thats great, however how would I wrap this information up in a JSON object? Sorry I am new to JSON and I am not sure if this is possible. You have given me food for thought though as your example is very similar to how we format our jsp pages at the moment. We tend to set parameters in the servlet get function and then use the jsp to format the data and add css class information although I am hoping to pass this through the JSON object as well.

    Could I ask a favour, would you mind explaining what the "aoColumns" tag tells dataTable to do internally with the sType field? Or point me something to read.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    1. JSON: just give it the HTML as a string. { "test_html": "..." } is valid json.

    2. The reason for my example using aoColumns and sType is to have DataTables treat the string as HTML. It will strip the HTML before doing sorting and filtering (so you can't filter on "
  • tcleggtclegg Posts: 4Questions: 0Answers: 0
    Thats great thanks for the speedy response.

    One other issue I have is that our current grid supports a select all rows button in the header row and an individual select checkbox on every row as the first column on the left hand side. Are there any examples of embedding objects within a table? One thought we had for select all was to use a class name and attach a click event to the class name but we're not sure about the check box on each individual row. To be honest I prefer the select row functionality as it is now but when you have urls in the row it makes things a litttle tricky.
This discussion has been closed.