Sort table by last visited rows

Sort table by last visited rows

tryxtryx Posts: 7Questions: 2Answers: 0

Hi,
I want to implement a custom sort on my server-side implementation of Datatable so that it is sorted by when each row was last visited. So if I have a table with 100 entries, the first 10 entries displayed would be the latest ones that was clicked by the user at some point. Remaining entries can be sorted in any order. How would I go about doing this?

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    You can use the order option to set the default table order. If your server side processing script follows the SSP Protocol it should use a query to order the results by that column.

    Kevin

  • tryxtryx Posts: 7Questions: 2Answers: 0

    Hi, I'm already aware of the 'order' option. Are you suggesting that when I 'click' on a row, I store the 'clicked date' in the table and then order using that value?

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    Sorry, I'm not clear on what you want to do.

    Datatable so that it is sorted by when each row was last visited.

    Not sure how you are keeping track of this but you can send any data you want to the server using ajax.data as a function. There are two examples shown in the docs. Then your server script can get the parameters you sent and you can use that to return the rows in the order you like.

    Kevin

  • tryxtryx Posts: 7Questions: 2Answers: 0

    Sorry, I will try to be more clear. If someone clicks on a row in the table, I consider that 'visited'. I want to sort the table based on a 'history of visited rows' I guess you can call it that. Currently, I do not store this information anywhere. However, I could store it in the session variable whenever I click on a row maybe. Then send this session data using ajax.data and sort using that data?

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Editor would make this easy. A click event on a record could automatically submit an edit(), which would then update the sorting column. Is that a thing you've considered?

    Colin

  • tryxtryx Posts: 7Questions: 2Answers: 0

    Unfortunately I can only use free resources. It looks like it's a paid plugin :/

  • tryxtryx Posts: 7Questions: 2Answers: 0

    A little update, I ended up posting a timestamp when I click a row and stored it in the database and sorted using that value on retrieval.

This discussion has been closed.