how to sort on a column that is calculated on screen load

how to sort on a column that is calculated on screen load

ninaSninaS Posts: 1Questions: 1Answers: 0

We have a database that holds cases. Cases have ages. We have a column for age but we only store it once the case has been closed and the age remains static. For cases that aren't closed, we calculate the age on the fly when the screen loads. Age is a complex calculation that takes holidays, weekends, and suspense times into consideration so is easier to handle in the web app using java calendar API rather than the DB. So at page load, the cases that are closed have the age populated by datatables because it's stored in the DB. The cases that are opened have the age calculated on the fly and put into the table on screen load.

The problem is, we only get say 30 cases per page at a time from datatables. And now the customer wants to be able to sort on age. How do we sort on age on a column where data doesn't exist yet? How do we grab the 30 oldest cases from the database when datatables doesn't know the age of all the cases in the DB yet? Is there some solution to this without having to rework our aging and having it done entirely in the DB?


  • colincolin Posts: 12,604Questions: 0Answers: 2,154

    If you are using serverSide, then yep, you would need to calculate that on server-side. If you're not, and all processing is on the client-side, then that should just happen automatically as the age would already be in the table, and therefore orderable.

    Can you post your table config, or link to your page, then we'll be able to understand more.


Sign In or Register to comment.