Hi,
I'm quite annoyed with the field selector which is on the table view, upper right of the page.
I do not want some fileds of the table to appear to logged (or not) users, only admins.
But, as I can select the fields, it's alaways possible to make a new selection on hidden fields there .. and I can't accept this
Any key ? May be a javascript routine ?
Hide fields select box
Re: Hide fields select box
Hi Hubert,
hiding the toggle-column-button depending on the current user or group using hooks only is quite complicated. You need to pass current member information from PHP to Javascript or Javascript needs to call a serverside PHP script via AJAX to find out who's logged in.
To hide the column-toggle-button for all users, you can try one of these simple jQuery solutions:
1. Hide button in all table views
Place the following code in hooks/header-extras.php:
2. Hide button in one table view
Create or open the file hooks/TABLENAME-tv.js and put the following code there:
From my point of view the toggle-button is very useful, because every single user can reduce the amount of information to the minimum s*he needs. I always use the "Hide in table view" checkbox in AppGini to definately hide columns.
By the way: My Toggle-panel looks a bit different than the default style:
Styled: Default:
Regards,
Jan
hiding the toggle-column-button depending on the current user or group using hooks only is quite complicated. You need to pass current member information from PHP to Javascript or Javascript needs to call a serverside PHP script via AJAX to find out who's logged in.
To hide the column-toggle-button for all users, you can try one of these simple jQuery solutions:
1. Hide button in all table views
Place the following code in hooks/header-extras.php:
Code: Select all
<!-- hooks/header-extras.php -->
<script>
$j(function() {
$j('button.tv-toggle').hide();
});
</script>
2. Hide button in one table view
Create or open the file hooks/TABLENAME-tv.js and put the following code there:
Code: Select all
$j(function() {
$j('button.tv-toggle').hide();
});
From my point of view the toggle-button is very useful, because every single user can reduce the amount of information to the minimum s*he needs. I always use the "Hide in table view" checkbox in AppGini to definately hide columns.
By the way: My Toggle-panel looks a bit different than the default style:
Styled: Default:
Regards,
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<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 readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Hide fields select box
Is there a way to pre-select(default) a few fields in the toggle so that every time the page loads, only the pre-select(default) field was being shown in the table view?
Any code?
Thank you.
Any code?
Thank you.
Re: Hide fields select box
(1) You can check "[X] Hide in table view" but this will hide them for everyone
(2) Have a look at localstorage in browser's dev-tools. There are entries like "columns_TABLENAME_view" which can be modified using Javascript. I never did this, but it should work if you set values according to your needs before AppGini reads those settings.
(2) Have a look at localstorage in browser's dev-tools. There are entries like "columns_TABLENAME_view" which can be modified using Javascript. I never did this, but it should work if you set values according to your needs before AppGini reads those settings.
- Attachments
-
- firefox_sSKUjTjtQa.png (23.69 KiB) Viewed 2141 times
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<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 readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Hide fields select box
I try it on the browser console:
It works and will unset and reset the columns-contact_view. I try it on contact.php in the hooks folder:
It somehow works but need to hit a refresh again to reflect the changes. I think it is because the native javascript loaded first. Any workarounds?
Code: Select all
window.localStorage.removeItem('columns-contact_view');
const field = {"contacts-department_id":true,"contacts-name":true,"contacts-email":true,"contacts-phone":true}
window.localStorage.setItem('columns-contact_view', JSON.stringify(field));
Code: Select all
$footer=<<<EOT
<script>
\$j(function() {
window.localStorage.removeItem('columns-contact_view');
const field = {"contacts-department_id":true,"contacts-name":true,"contacts-email":false,"contacts-phone":false}
window.localStorage.setItem('columns-contact_view', JSON.stringify(field));
});
</script>;
EOT;
Re: Hide fields select box
Did you try in header-extras.php?
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<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 readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Hide fields select box
Just for sharing. It works in certain extents.
But, if there is changes on toggle fields, it will not persist over the page or refresh.
I guess the cookies will be re-write for every refresh or page navigation.
But, if there is changes on toggle fields, it will not persist over the page or refresh.
I guess the cookies will be re-write for every refresh or page navigation.
Re: Hide fields select box
I think if the localStorage value does not exist, you should write your default value, otherwise don't touch it.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<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 readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Hide fields select box
This code shall works at header-extras.php
Code: Select all
<script>
\$j(function() {
if (localStorage.getItem("columns-contact_view") === null){
const field = {"contacts-department_id":true,"contacts-name":true,"contacts-email":false,"contacts-phone":false}
window.localStorage.setItem('columns-contact_view', JSON.stringify(field));
}
});
</script>;