Previously, with a coded table, I could either run a separate count query within the while loop to generate the counts, or I could use "COUNT(CASE WHEN this = that THEN 1 END)" inside the existing query.
I am looking to do the same inside my editor datatable.
In the Mjoin example I linked to, the Permissions column could show a count by using:
{ data: "permission.length" }
permission is an array of data (in this case you could just have it with an id property only - since you aren't using anything else for it - e.g. labels like I have in the Mjoin example).
That said, it is possible to execute SQL functions such as COUNT as a field instance by using:
Field::inst('assets')
->dbField('COUNT( ... )')
->set(false) // not writeable
Answers
Do you mean a query per row? If so, you'd be best served using Mjoins and then displaying the length of the array in the DataTable.
Allan
Not sure this help me, apologies if I don't understand that functionality fully.
Here is a pic of my old table, as you can see I have outlined my count column. Can Mjoins do that?
Previously, with a coded table, I could either run a separate count query within the while loop to generate the counts, or I could use "COUNT(CASE WHEN this = that THEN 1 END)" inside the existing query.
I am looking to do the same inside my editor datatable.
Hope that explains better.
Hi,
In the Mjoin example I linked to, the
Permissions
column could show a count by using:permission
is an array of data (in this case you could just have it with anid
property only - since you aren't using anything else for it - e.g. labels like I have in the Mjoin example).That said, it is possible to execute SQL functions such as COUNT as a field instance by using:
Regards,
Allan
Awesome, thanks for taking the time to clarify Allan.