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:

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:

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.