Posted in Entity List, Power Apps Portals

Power Apps Portals – Entity List: Removing Sort/Order By from column

Hi, today I am going to talk about how to remove the Sort / Order By for a column within an Entity List in Power Apps Portals.

There are a few different ways on achieving that, I am going to show you a way using JavaScript/jQuery to change the element type representing the column header.

I am creating a simple Entity list pointing to the Active Contact view from my CDS environment, at this point all columns are sortable:

sort01

Now I am going to write a JavaScript code, where I am getting the column for the “Full Name” attribute (index 0) and replacing the <a> element for a <span> element.

I am adding this logic to the load event of the Entity List, to make sure it will apply if the user performs a sorting in the other columns, I am also validating the header name (aria-label) before performing the action, the reason for this is because once another load happens (a sort in the other columns for example), the index 0 for my list is now the Email column, which I don’t want to disable sorting in my scenario.

Code to be added in the JavaScript section against the Entity List record:

$(document).ready(function() {
    DisableSort();
});
DisableSort = function() {
    var list = $(“.entitylist.entity - grid”).eq(0);
    list.on(“loaded”, function() {
        var columnIndex = 0; // index of column you want to remove sorting
        var columnName = “Full Name”; // name of column you want to remove sorting
        var column = list.find(“table thead th a”).eq(columnIndex);
        if (column) {
            var text = column.attr(“aria - label”).trim();
            if (text == columnName) {
                column.find(“span”).remove();
                var newElement = “ < span > ”+columnName + “ < /span>”;
                column.replaceWith(newElement);
            }
        }
    });
};

Now the column Full Name for my Entity List is disabled for Sort/Order By:

sort02

You could find better ways to retrieve the column index, this is just a simpler code to achieve a common requirement in Power Apps Portals.

I hope you found this post useful.

3 thoughts on “Power Apps Portals – Entity List: Removing Sort/Order By from column

  1. Hello,

    It’s possible do the contrary action? We need to add the sort action in one column of one html table created vía liquid template.

    Like

  2. Hi Oliver,
    I followed one of your blog where we show hide records in an entity list , conditionally. I am facing one issue on that, My entity list page size is 500, total records 950. Now, after adding conditions, left out records are 400, still the list shows both the pages and the 2nd page shows 0 records. How can I resolve this?
    The pages aren’t reordering.

    Like

Leave a reply to Sandra Cancel reply