Sep 28 2023 03:56 PM
I have a calculated column which is populated with content from my custom Subject column, and if that is blank then it falls back to what is in the standard Name column (or a tracked version of that, since Name is bizarrely not available as a column choice in a calculated column).
Now I want that to act as a hyperlink in the same way as the Name column, I.e. to move into the folder (if it’s a folder) or open the file (if it’s a file). It’s like a substitute Name column.
Is this possible?
Sep 28 2023 10:32 PM
@drmrbrewer Apply below JSON column formatting for your calculated column:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"customRowAction": {
"action": "defaultClick"
}
}
You can customize the style (font/color, etc.) of the column as per your requirements if needed.
Documentation: Use column formatting to customize SharePoint
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
Sep 29 2023 12:03 AM
@ganeshsanap thanks for the reply!
Your custom formatting provides the column with the click navigation functionality, but it's still not formatted as a hyperlink (to show it's clickable). Is it possible to do that, without messing up the defaultClick action?
Ideally it would also be nice to have the same hover behaviour as the standard Name column, which appears as plain text (not blue underlined) until you hover over it, and then it is underlined as a hyperlink (still not blue).
Sep 29 2023 12:55 AM
Solution@drmrbrewer Try using this JSON:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": "ms-Link"
},
"customRowAction": {
"action": "defaultClick"
}
}
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
Sep 29 2023 01:13 AM
@ganeshsanap genius! Very nice!
I'll definitely mark this as the answer, because it does what I asked for... but for the icing on the cake: the standard Name column also has a "Share" and "Three-dot menu" that appear in the field when you hover over it, giving you more options to do stuff with that item. Since I'm trying as far as possible to create a replacement for the Name column, is there something I can add to the JSON format to add these contextual actions too?
Sep 29 2023 06:10 AM
@drmrbrewer I am not sure if you can make it visible on hover similar to default Name column but you can use below JSON which will show (...) next to column value always and open the context menu on click of the icon:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": "ms-Link"
},
"customRowAction": {
"action": "defaultClick"
}
},
{
"elmType": "span",
"style": {
"margin-left": "15px",
"font-size": "16px",
"cursor": "pointer"
},
"attributes": {
"iconName": "More"
},
"customRowAction": {
"action": "openContextMenu"
}
}
]
}
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
Sep 29 2023 06:26 AM
Sep 29 2023 12:55 AM
Solution@drmrbrewer Try using this JSON:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": "ms-Link"
},
"customRowAction": {
"action": "defaultClick"
}
}
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.