how to hide or show the column(s) via table

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
D Campbell
Posts: 20
Joined: 2017-03-12 09:32

how to hide or show the column(s) via table

Post by D Campbell » 2017-08-22 20:27

the title says all... please help me as I spent two hours figuring how to do that and where or which file to put the "working" codes of show and hide the columns to have the table downsize or back to normal? thanks!

User avatar
Bachtiar
Posts: 5
Joined: 2017-08-26 15:28

Re: how to hide or show the column(s) via table

Post by Bachtiar » 2017-10-20 14:51

Up this topic .. I need solution too

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: how to hide or show the column(s) via table

Post by AhmedBR » 2017-10-22 20:06

AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

D Campbell
Posts: 20
Joined: 2017-03-12 09:32

Re: how to hide or show the column(s) via table

Post by D Campbell » 2017-10-26 18:48

I need something like http://makitweb.com/how-to-hide-and-sho ... ng-jquery/ or https://jsfiddle.net/highwayoflife/8BahZ/4 for table.

I spent few hours trying to put pieces together and try to execute it but failed many times. My co-worker wants to control and minimize some columns.

Here's image of what I did so far... https://photos.app.goo.gl/XcgkqAFG0WRwCJB53

Please help me with this and my deadline is in TWO HOURS!

MANY MANY MANY THANKS :roll:

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

Re: how to hide or show the column(s) via table

Post by a.gneady » 2017-10-26 20:00

Here is a starting point: each column has a class named "tablename-fieldname" ... You can use that to select the entire column and hide/show it .. To try this live, go to the 'Customers' table of our online demo at https://bigprof.com/demo/customers_view.php ... Press F12 to open the inspector of your browser, and go to the console window and type this command:

Code: Select all

$j('.customers-CompanyName').hide()
If you press Enter, the above code would hide the 'CompanyName' column. To show it again:

Code: Select all

$j('.customers-CompanyName').show()
You can place the above code inside some checkbox/button handler inside the hooks/tablename-tv.js file (where tablename is the name of the concerned table -- create that file if it's not there).
: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.

D Campbell
Posts: 20
Joined: 2017-03-12 09:32

Re: how to hide or show the column(s) via table

Post by D Campbell » 2017-10-27 15:13

Awesome, Thank you! I have tried it and it works with this simple line of code.

One problem is if I enter to update the record or click on one of records while details view was on same page to update the information. The whole table just returns to original position with all fields showing there rather than keep one or few columns remains hide until the user clicks to show or something?

Is there a way to do that or too complicated?

Thanks again!
Dave

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

Re: how to hide or show the column(s) via table

Post by a.gneady » 2017-10-30 12:12

Hmm .. it can be done but might get a bit complicated :)
You can store the column hide/show options inside cookies and read it from there on page load using JS code similar to this:

Code: Select all

// set a cookie
Cookies.set('fieldname', 'hide');

// get a cookie and use it to show/hide a column:
var hide = Cookies.get('fieldname');
if(hide == 'hide'){ $j('.tablename-fieldname').hide(); }
: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.

D Campbell
Posts: 20
Joined: 2017-03-12 09:32

Re: how to hide or show the column(s) via table

Post by D Campbell » 2017-11-07 18:23

Hi, I finally got around to that and tried this script.... it works but I couldn't figure out how to "refresh" cookies or "delete" a cookie?

I tried to add same script but changed from 'hide' to 'show' but it did nothing.

For now, when I click on a column and turn it off (hide it) then it stored into cookies, and it became permanent. I am able to show it but it returns to hide when click on something or refresh a page.

Do you guys know how to refresh with new cookies or something?

D Campbell
Posts: 20
Joined: 2017-03-12 09:32

Re: how to hide or show the column(s) via table

Post by D Campbell » 2017-11-08 15:01

I came up with this but can't get it to working.. what did I do wrong?

HTML: <input type="checkbox" name="checkfieldname" />

JavaScript:
Cookies.set('fieldname', 'hide', 'show');

// get a cookie and use it to show/hide a column:
var hide = Cookies.get('fieldname');
var show = Cookies.get('fieldname');
var $checkfieldnameInput = $('input[name="checkfieldname"]');

$checkfieldnameInput.on('click', function(){
if ( $(this).is(':checked') )
if(hide == 'hide'){ $j('.tablename-fieldname').hide(); }
else
if(show == 'show'){ $j('.tablename-fieldname').show(); }
});

Abeer
Posts: 18
Joined: 2017-03-12 09:19

Re: how to hide or show the column(s) via table

Post by Abeer » 2017-11-09 05:38

i think you should do it like that:

Code: Select all

// get a cookie and use it to show/hide a column:
var status = Cookies.get('fieldname');
if(status == 'hide'){ $j('.tablename-fieldname').hide(); }
else
if(status == 'show'){ $j('.tablename-fieldname').show(); }

var $checkfieldnameInput = $('input[name="checkfieldname"]');

$checkfieldnameInput.on('click', function(){
if ( $(this).is(':checked') ){
$j('.tablename-fieldname').hide();

//set cookies to hide
Cookies.set('fieldname', 'hide');

}else{
$j('.tablename-fieldname').show();

//set cookies to show
Cookies.set('fieldname', 'show');

}

});

D Campbell
Posts: 20
Joined: 2017-03-12 09:32

Re: how to hide or show the column(s) via table

Post by D Campbell » 2017-11-17 22:03

Hi,

I tried that one and it was not working at all.

I copied and pasted the code and change the filename and tablename on there... it was saved on tablename-dv.js or at hooks/footer-extras.php with script there then I use datalist.php to put codes in there on top of the table after line 837:

I tried to get it work on either codes:

$this->HTML .= '<div>';
$this->HTML .= '<b>Date</b>: <a href="#" onClick="function test(){$j(\'. tablename-fieldname\').hide(); } test(); return false;">Off</a>&nbsp;:&nbsp;<a href="#" onClick="function test(){$j(\'.tablename-fieldname\').show(); } test(); return false;">On</a>&nbsp;';
$this->HTML .= '</div>';

or

$this->HTML .= '<div>';
$this->HTML .= '<b>Date</b>: <input type="checkbox" name="checkfieldname" />&nbsp;';
$this->HTML .= '</div>';

thanks and greatly appreciated!

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

Re: how to hide or show the column(s) via table

Post by a.gneady » 2017-11-22 17:31

We're adding this feature to the upcoming AppGini 5.70 without custom coding .. Stay tuned!
: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.

D Campbell
Posts: 20
Joined: 2017-03-12 09:32

Re: how to hide or show the column(s) via table

Post by D Campbell » 2017-12-19 22:22

Great to know.. let me know when it comes out. Very soon, I hope. :)

Post Reply