Power Apps Portals allows us to add custom JavaScript/jQuery code to manipulate behaviour within the Portals website.
I am starting a series of quick posts with snippets of JavaScript/jQuery code to help you with your Power Apps Portals implementation.
When talking about client-side customization, there is no single way of interacting with the page elements, there are several ways to achieve same results, in this post I will give an example on how to hide & show elements in your page, so here we go:
Hide & Show Fields
$("#<field name>").closest("td").find("div.control, div.info").hide(); // show();
Hide & Show Section
$("table[data-name='<section name>']").parent().hide(); // show();
Hide & Show Tab
$("div[data-name='<tab name>']").prev("h2.tab-title").hide(); // show();
$("div[data-name='<tab name>']").hide(); // show();
Hide & Show Entity List/Sub-grid column
var list = $(".entity-grid")
list.on("loaded", function () {
list.find("th:contains('<column display name>')").hide(); // show();
list.find("td[data-th='<column display name>']").hide(); // show();
});
Hide & Show Option Set value
$("#<field name> option[value='< option set value>']").hide(); // show();
Do you have any suggestions or requests for another JavaScript tip? Let me know in the comments below.