Add count of related child records to DataTable?
Add count of related child records to DataTable?
I have my DataTables working perfectly using Server Side Processing to display a list of HelpDesk tickets in my application. I now need to add a column (or to an existing column) a count of comments for each ticket. Basically I want each row (HelpDesk Ticket) to somewhere say "Comments: 3 (or what ever the count is.) I am having trouble with this.
I tried altering the Server-Side scripts $sQuery to include a column such as (Select count(id) FROM helpdesk_comments WHERE ticket_id = helpdesk.id) as cmntcount
Running such a query in MySQL works perfectly but I get a DataTable error when using it. Can somebody recommend an appropriate method to do this? I don't care when or how this comment count gets added to my records so long as it gets added.
As a side note, once I get the count added, my users then need to be capable of clicking or hovering over the count and have a UI_DIALOG or something query and display the comments. Any suggestions for that would be greatly appreciated as well.
Sincerely,
Lee Goolsby
I tried altering the Server-Side scripts $sQuery to include a column such as (Select count(id) FROM helpdesk_comments WHERE ticket_id = helpdesk.id) as cmntcount
Running such a query in MySQL works perfectly but I get a DataTable error when using it. Can somebody recommend an appropriate method to do this? I don't care when or how this comment count gets added to my records so long as it gets added.
As a side note, once I get the count added, my users then need to be capable of clicking or hovering over the count and have a UI_DIALOG or something query and display the comments. Any suggestions for that would be greatly appreciated as well.
Sincerely,
Lee Goolsby
This discussion has been closed.
Replies
Thanks for this great DataTables!!!
Sorry you've been having a bit of a monologue there - but good to hear you've got it sorted out. Have you got a link you can share with us - sounds quite nice!
Allan