Disable all links in a table (tableview) row

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
User avatar
jmcgov
Veteran Member
Posts: 79
Joined: 2018-12-19 01:31
Location: Northern Ireland

Disable all links in a table (tableview) row

Post by jmcgov » 2019-01-23 13:52

I thought I'd share this, as I find it handy and it took me a while to figure it out.

Three points first
- it may not be well done, as I'm not good on jquery
- I dont think it is secure, ie it does not prevent someone from opening the disabled link (if they chose to construct it)
- Credit to Ahmad, as it is based on his solution in this thread https://forums.appgini.com/phpbb/viewto ... f=7&t=1322

Problem: I have an app with
- a table, called p02_orders
- which has a filed Quantity
- for reasons (of no consequence), I want to prevent users from opening the detail view, if the Quantity=600
- I also want to colour code the table row

Solution:
- go to hooks p02_order
- go to function p02_orders_header
- between case 'tableview' and break, enter the code, below
- I could also hide the row, by adding class 'hide' instead of 'danger

Hope it helps someone :)

$header="<%%HEADER%%><script>
\$j(function(){
\$j('td.p02_orders-Quantity').each(function(){
if(\$j(this).text() == '600'){
\$j(this).parent().addClass('danger');
\$j('tr.danger a').each(function(){
\$j(this).addClass('btn disabled');
})
}
else{
\$j(this).parent().addClass('success');
}
})})</script>";

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Disable all links in a table (tableview) row

Post by a.gneady » 2019-01-24 13:51

Thanks for sharing, @jmcgov :)
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Disable all links in a table (tableview) row

Post by pbottcher » 2019-01-24 20:25

Hi,

just a suggestion. If you want you can also add to the detailview a check if your specific value for the ID passed matches your "dont show the details" (=600 in your sample), redirect the user to the tableview.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
jmcgov
Veteran Member
Posts: 79
Joined: 2018-12-19 01:31
Location: Northern Ireland

Re: Disable all links in a table (tableview) row

Post by jmcgov » 2019-01-29 13:13

Thanks pböttcher

Post Reply