Page 1 of 1

Disable all links in a table (tableview) row

Posted: 2019-01-23 13:52
by jmcgov
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>";

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

Posted: 2019-01-24 13:51
by a.gneady
Thanks for sharing, @jmcgov :)

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

Posted: 2019-01-24 20:25
by pbottcher
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.

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

Posted: 2019-01-29 13:13
by jmcgov
Thanks pböttcher