sorting based on two columns, results alternate between columns.

sorting based on two columns, results alternate between columns.

rockyinteractiverockyinteractive Posts: 2Questions: 0Answers: 0
edited March 2010 in General
I'm not sure if this can be done, but I would love to be able to sort based on two columns and have the results alternate between both columns. I have a list of employees names/phone numbers and instead of listing them all in one column, I wanted to create a two column table and still have the ability to sort/filter both columns.

So instead of the results getting returned to just the one column, the first result would go in row 1 col 1 and the second result would go in row 1 col 3, the third result would go in row 2 col 1, and the next row 2 col 3...etc

I want to eliminate some scrolling and use the horizontal size that I'm given.

Example:
[code]


Person (col 1)
 
Person (col 2)


Bob
 
Fred


Joe
 
Greg


Jill
 
Sarah


[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I'm afraid that this isn't really possible in DataTables at the moment. DataTables is entirely row based for filtering / sorting, so 'cell' based processing isn't supported. For example, if you applied a filter to the above table which took out only 'Greg', then you would need to move Jill up a row and across the columns, and Sarah to the first column.

    It's possible to do this when using server-side processing, because DataTables doesn't really care what the data that is returned from the server is - so on the server-side you just apply the loop as needed, but not really when using client-side processing. Sorry.

    Allan
  • rockyinteractiverockyinteractive Posts: 2Questions: 0Answers: 0
    server side processing isn't a problem.

    Is there a way to process the date before it gets pushed to the table? For example, I have a url that I would like to build and wrap around a title and image. Would you recommend returning the output as a built link or is there some sort of processing that could manipulate the data before building the table.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Assuming your are going with server-side processing, then you can build up the return string with whatever HTML you want. IMG tags, whatever, it's all just plain text to DataTables, and it will insert the string using innerHTML - so your HTML will render.

    Allan
This discussion has been closed.