Regarding the ActionColumn (link) in the datagrid, I am using ExternalURL to set the link destination based on the URL in the following data:
Columns: Title, URL
A, https://a.com
B, https://b.com
None, empty
I want to disable the datagrid link when the Title is "None" after the datagrid data is displayed.
Is there a good way to achieve this?
Even when I use AddCellCssClass in the datagrid's OnInitialize, or try the disable link JS on the screen, it doesn't work well.
Hi R R,
You can use the following JS snippet in the OnInitialize event of the data grid:
I highlighted the parameters that you need to change in your code (the column bindings).
I also attached a sample OML for reference.
Thank you!Wishing you a successful and prosperous New Year!
There are some solutions:
Hope this help
Option 1 (Recommended Approach): Regulate the URL Value Directly
Instead of attempting to hide the link visually, prevent navigation by omitting the URL when the Title is "None".
Implementation Method:
Assign an expression to the ActionColumn’s ExternalURL:
If(Title = "None", "", URL)
Outcome:
Entries with Title = "None" will not trigger navigation, rendering clicks ineffective. This requires no JavaScript and functions reliably.
Option 2: Conditional Display with a Custom Column
For comprehensive control over the user interface:
Substitute the ActionColumn with a Text/Link widget placed within a Template Column and render the link conditionally:
If(Title <> "None", Link, Text)
The link will only display when valid, while non-clickable text will show when Title = "None". This method is fully supported and behaves predictably.
Option 3: Disable Interaction with CSS (Visual Only)
If retaining the ActionColumn is essential:
.disabled-link {
pointer-events: none;
color: #999;
cursor: default;
}
Apply this class conditionally once the data is loaded (for example, OnAfterFetch).
Utilize Option 1 if you want to disable navigation logically, or choose Option 2 for greater UI control. The OutSystems Data Grid is driven by data, making expressions and data the most dependable means to manage behavior rather than manipulating the DOM.
I hope this helps.