⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Replace url filename with custom text



navajo
  • profile picture
  • Member

Posted 19 January 2019 - 21:12 PM

Hi there..

 

 

Can't seem to get my head around this issue...

 

I want to replace the file url listed in a row with an alternate text such as "View File".

 

[attachment=1346:img.jpg]

 

 

Any suggestions?


NadimD
  • profile picture
  • Member

Posted 21 January 2019 - 00:28 AM

Greetings !

 

You can use a callback on the column to achieve that :

 

https://www.grocerycrud.com/documentation/options_functions/callback_column

 

Let me know if this works for you.


navajo
  • profile picture
  • Member

Posted 25 January 2019 - 13:53 PM

Hi NadimD

 

Thank you, that is what I was trying to use, but had an error in my syntax, but sorted it out. Now just to figure out how to activate a callback when the  link is clicked.

 

Thanks for taking the effort to reply.


NadimD
  • profile picture
  • Member

Posted 30 January 2019 - 13:41 PM

You're welcome !

 

Well, to make a callback on the clicked link, that would be out of Grocery Crud since the click is handle by the browser.

That means you could either add a onclick='yourcallback();' on your link, and make a JS function yourcallback() , or you can init a click event with jQuery, outside GroceryCRUD.

 

Make sure you load jQuery or any library you use to handle the clicks if you use a library, and that's it !

If the callback is supposed to happen after the link is clicked, on the target, that would be server-side !

 

Let me know if you understand and feel free to provide me more details.

 

I personnally don't want to get into the GCRUD React scripts, they can be updated any time and I'm not a React developer, so I handle everything else in my own script.js using jQuery.

 

That's how I made a "preview" button for instance, I have a table "articles" with a text field, and I added a preview button near the Save button to achieve custom events.