Jump to content

Conditionally Disable View Details record action


Recommended Posts

Hello! Is there a way to  disable the "View Details" record action if a certain [Field:Name] = "Test1"

I already have datapages where the link to the details page is through a html block, and that is easy to hide based on a condition using javascript.

Thanks in advance !

Link to comment
Share on other sites

Hi @bookish

I think this article can help you achieve your goal.
https://howto.caspio.com/tech-tips-and-articles/disabling-inline-edit-option-in-reports-based-on-a-condition/

image.thumb.png.40a2141e9129013ec797df8dff2645a7.png

You can change the InlineEdit with 'DetailsLink'
And of course you could change the the condition in CalculatedField according to your needs.

Hope it helps

Link to comment
Share on other sites

Hi @bookish

You can do it without JavaScript

1. Use the calculated field to return a link you need as an HTML string. For example:

CASE WHEN [@field:Name]= "Test1" THEN '<a href="detailsLink?parametername='+ [@field:RandomID]+ '">Details page </a>'  ELSE ''  END

image.png.3b7c00106dbf90531ffd7f4c4b5b6197.png

2. Add this calculated field as HTML to HTML block:

image.png.3de076635d98ab64d00e3722d2a110f0.png

3. Place the calculated field in 1st position and add the following CSS in the header of your DataPage:

<style>
dt:nth-child(1),
dd:nth-child(2) {
display: none;
}

</style>

Hope it helps

Link to comment
Share on other sites

Thank you very much @Ilyrian and @Volomeister for the proposed solutions.

The solution not to use a Javascript did not work for me. The Calculated field was not working. And as the View Details link still appeared, I thought I should choose No in "Do you need a Details Page for each record?" But the Calculated field seems to require a new datapage for which I don't have any more allowance in my plan.

I went back to the topic which I started, use the solution of @DefinitelyNot31337 and it worked with my LIST type of report

I just replaced all pertinent words with DetailsLink. 
 

Link to comment
Share on other sites

Hi @bookish

You can use the following JavaScript to remove default details link from the List report:

 

<script>

if (typeof rowPosition == 'undefined') {

const rowPosition = 1
const targetValue = 'Test1'

const removeDetailLinks = () => {
document.querySelectorAll('[class*="cbResultSetListViewTable"]').forEach(container => {
    if(container.querySelector(`.cbResultSetData:nth-of-type(${rowPosition})`).innerText.trim() == targetValue) {
    document.querySelector('.cbResultSetPanelColumnarRAContainer').remove()
    }
})
document.removeEventListener('DataPageReady', removeDetailLinks )
}


document.addEventListener('DataPageReady', removeDetailLinks )
}

</script>

Where rowPosition is the position of the row where [Field:Name]  label and its value are displayed
targetValue stores the value you would like to check against. So when the value of  [Field:Name] equals to targetValue, the details link will be removed

Link to comment
Share on other sites

On 4/27/2023 at 6:56 PM, Volomeister said:

Hi @bookish

You can use the following JavaScript to remove default details link from the List report:

 

<script>

if (typeof rowPosition == 'undefined') {

const rowPosition = 1
const targetValue = 'Test1'

const removeDetailLinks = () => {
document.querySelectorAll('[class*="cbResultSetListViewTable"]').forEach(container => {
    if(container.querySelector(`.cbResultSetData:nth-of-type(${rowPosition})`).innerText.trim() == targetValue) {
    document.querySelector('.cbResultSetPanelColumnarRAContainer').remove()
    }
})
document.removeEventListener('DataPageReady', removeDetailLinks )
}


document.addEventListener('DataPageReady', removeDetailLinks )
}

</script>

Where rowPosition is the position of the row where [Field:Name]  label and its value are displayed
targetValue stores the value you would like to check against. So when the value of  [Field:Name] equals to targetValue, the details link will be removed

Thank you very much @Volomeister I will use this in similar needs in the future! :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...