Top N per group query in the AJAX API?

Posted by Rollbase User on 11-Dec-2012 10:16

Does anyone know if there's a way to do a "top N per group" query in the AJAX API?

All Replies

Posted by Admin on 12-Dec-2012 02:28

It seems you can actually get this information in a single AJAX request, using reports. You can create a report that outputs the "top N per group" list, then in your Page send an AJAX request for that report. You can use the report's merge token to get the report's URL into the page reliably.



You can use the CSV report type to make the result purely the text you output in the report. I'm outputting simple CSV that I then parse into data in the JavaScript. You can also use the XML report type to make it into an XML document, that you can then access using DOM methods in JavaScript. You can use the Plain Text report type, but it actually embeds your report output into some simple HTML, so you'd have to extract it. Might as well use the CSV type if you're looking for plain text.



This seems like a roundabout way to do it. I'd be curious to hear if anyone has any other ideas about how to achieve this. I'm trying to avoid making one query per group. That does actually work, and it's reasonably fast, but it ca

This thread is closed