Re: Displaying Dataverse Table as Accordion in Power Pages
Efficient - depends on exactly what you need to do.
If you knew it would only ever be a limited number of records, then probably a Liquid fetchxml call in the Web Template/Page Content, then populate JSON or JavaScript object to use in your acordian.
If the number records could be large 5,000+ then you would also need to architect it to make next calls.
If the expanded content was coming from another table, then you may do an initial population via Liquid fetchxml, and the populate the expanded content on click via the web api.
In such cases, try to do the initial fetchxml call in Liquid - if the initial call is via the Web API (or an Ajax workaround) your user will most likely notice lag as the JavaScript wont run until after the page is presented to the user, then it has to do a round trip to the portals cache/dataverse to get the data for you to then manipulate, (vs data is there when the page renders in the browser, then manipulate)
Liquid runs server-side (the output of which gets sent to the browser for it to render)
JavaScript runs client-side (after the browser has started rendering) -
JavaScript cannot directly invoke Liquid, but Liquid can create JavaScript snippets and variables. JavaScript can make a Web API call, or can get some Liquid output indirectly via an Ajax call to another Web Page that has Liquid behind it (but usually this is not often needed these days due to the Web API).