Hide Row based on value

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
jfehr
Posts: 11
Joined: 2022-01-25 17:03

Hide Row based on value

Post by jfehr » 2022-01-29 15:19

Hi i have a code i use the Highlights rows based on what selected.
i like to Hide a row for example if(status == 'Invoiced') like to hide that row.
can anyone Help?
Thanks.
<script>
$j(function(){
$j('.Tickets-Status').each(function(){
var status = $j(this).text();
if(status == 'New'){
$j(this).parents('tr').addClass('info');
}
if(status == 'Complete'){
$j(this).parents('tr').addClass('success');
}
if(status == 'Invoiced'){
$j(this).parents('tr').addClass('warning');
}
if(status == 'On Hold'){
$j(this).parents('tr').addClass('danger');
}
if(status == 'Close'){
$j(this).parents('tr').addClass('danger');
}
})
})
</script>

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1944
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Hide Row based on value

Post by jsetzer » 2022-01-29 17:12

Instead of using javascript for hiding the already loaded table rows, what about filtering records already on serverside using AppGini's built in filtering options?

Doing it that way the pagination/paging would still work as expected and not showing misleading values ("Showing records 1-10 of 60" First/Prev/Next/Last buttons, Page 1 / 2 / ...)

Just an idea.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 25.10 + all AppGini Helper tools

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1944
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Hide Row based on value

Post by jsetzer » 2022-01-29 17:19

Code: Select all

// ...
if(status == 'Invoiced')
  $j(this).closest('tr').fadeOut(); 
  // or $j(this).closest('tr').hide();
  // or $j(this).closest('tr').addClass('hidden');
// ...
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 25.10 + all AppGini Helper tools

jfehr
Posts: 11
Joined: 2022-01-25 17:03

Re: Hide Row based on value

Post by jfehr » 2022-02-01 01:37

jsetzer Thank you so much for you reply.
1st option seems like a much better idea.
only Problem is i m not familiar with these filtering options.
any help would be much appreciated.

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1944
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Hide Row based on value

Post by jsetzer » 2022-02-01 05:03

Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 25.10 + all AppGini Helper tools

jfehr
Posts: 11
Joined: 2022-01-25 17:03

Re: Hide Row based on value

Post by jfehr » 2022-02-01 05:09

Is there a way to run this link
<a href="http://localhost/jfs/Tickets_view.php?S ... >Filter</a>

when opening this one?

<a href="Tickets_view.php"></i>Tickets</a>

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1944
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Hide Row based on value

Post by jsetzer » 2022-02-01 06:00

chrome_8bk9ZffLh2.png
chrome_8bk9ZffLh2.png (10.84 KiB) Viewed 2779 times
Hi, when posting code (for example HTML, PHP, CSS or Javascript-code, here: your links) can you please use [code] ... [/code]. This will help us reading your post and helping you. Thank you.

See here:
app.php/help/bbcode#f2r1
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 25.10 + all AppGini Helper tools

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1944
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Hide Row based on value

Post by jsetzer » 2022-02-01 06:11

jfehr wrote:
2022-02-01 05:09
Is there a way to run this link
<a href="http://localhost/jfs/Tickets_view.php?SortField=&SortDirection=&FilterAnd%5B1%5D=and&FilterField%5B1%5D=13&FilterOperator%5B1%5D=not-equal-to&FilterValue%5B1%5D=Invoiced">Filter</a>

when opening this one?

<a href="Tickets_view.php"></i>Tickets</a>
Well, there are many places where you would have to replace the original link by the custom link. If I was you, I would not do so.

Alternatives:
  • You can add the link for the filtered view into menu
    see hooks/links-navmenu.php
  • You can add the link for the filtered view to your homepage
    see hooks/links-home.php
  • You can add filters in TABLENAME_init() function as described here:
    https://bigprof.com/appgini/tips-and-tu ... ult-filter
  • If you don't want users of a certain group to see those invalid records, you can consider changing ownership of those records to a user of a different group (for example to "admin") using set_record_owner function, then limit read-permissions for the group to "Group only". As admin you will still see those records, but the users will not. Just as an idea.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 25.10 + all AppGini Helper tools

Post Reply