Row Toggle Action Icon/Button

Row Toggle Action Icon/Button

ZefxZefx Posts: 8Questions: 4Answers: 1

I'd like to implement a "Mark as Read" icon or button.

I envisage this as similar to the way gmail and such work.

It would operate rather like the delete button on the following example, but would automatically update the backend without a confirmation dialog. It would also need to change something visual on the row - ideally styling and the icon (eg a closed vs open envelope icon).
https://editor.datatables.net/examples/inline-editing/fullRow.html

Pointers would be appreciated!
Thanks
Joe

Answers

  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954

    If you are using Editor then maybe something like the checkbox example will work. You can add some code to rowCallback to highlight the row based on the whether its marked as read or unread. Similar to this example but use rowCallback instead.

    Kevin

  • ZefxZefx Posts: 8Questions: 4Answers: 1

    Yes, using Editor, hadn't thought to use checkboxes.

    Functionally that would work but ideally I'd like an icon, so that I can have read, flagged, etc as more clear in the UI...

  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954

    You can use icons. Maybe different values for each one depending on how you store them in the DB. It will take some slight modifications of the columns.render function to display the icons. Modification of the event handler to send the selected value to the DB and rowCallback to perform the appropriate highlighitng.

    Kevin

  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954
    edited January 2023

    Maybe use 0 for unread, 1 for read, 2 for flagged, etc. You can combine the values and if it has, for example, a 1 and 2 you can mark it as read and flagged.

    EDIT: Or you can just have different fields in the row data for read, flagged, etc.

    Kevin

Sign In or Register to comment.