AppGini Tableview Quickie: remove record-selector checkboxes

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 264
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

AppGini Tableview Quickie: remove record-selector checkboxes

Post by jsetzer » 2019-07-03 17:24

Hi AppGineers out there,

for a pure readonly tableview I wanted to remove the checkboxes at the begining of each row:

chrome_2019-07-03_19-16-30.png
chrome_2019-07-03_19-16-30.png (8.12 KiB) Viewed 443 times

I was hoping that $options->AllowSelection = 0 in TABLENAME_init() function would do that job, but unfortunately it doesn't :| and I did not find any other way.

So I ended up with the following JavaScript code in TABLENAME-tv.js:

Code: Select all

$j(function(){
    $j("#order-by-selector").closest("tr").hide().remove();
    $j("#select_all_records").closest("th").hide().remove();
    $j(".record_selector").closest("td").hide().remove();
});
Now the selectors have been removed and the result comes close to my expectation:

2019-07-03_19-20-03.png
2019-07-03_19-20-03.png (6.87 KiB) Viewed 443 times

KindRegards,
Jan

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 628
Joined: 2018-04-01 10:12

Re: AppGini Tableview Quickie: remove record-selector checkboxes

Post by pböttcher » 2019-07-03 21:11

Hi Jan,

you need to set the table permission for that table (for the user/group that should have a read-only view without selection capabilies) to NOT have the edit/delete permissions on that table.

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 325
Joined: 2019-05-21 22:42
Contact:

Re: AppGini Tableview Quickie: remove record-selector checkboxes

Post by onoehring » 2019-07-04 04:19

Hi pbötcher,

I see both your points, but believe Jan needs to have edit permissions of the user but wants the "ugly" go away.
In my screenshot I am a regular user in my application, but can to nothing except print preview with that checkboxes, so thanks Jan for your code.
ec_50.png
ec_50.png (8.26 KiB) Viewed 426 times
Unfortunately the checkboxes are gone for everyone then. Is there a chance to keep them for certain groups? I would know how to do this in php but in the -tv table?

Olaf

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

Re: AppGini Tableview Quickie: remove record-selector checkboxes

Post by jsetzer » 2019-07-04 05:32

pböttcher wrote:
2019-07-03 21:11
Hi Jan,
you need to set the table permission for that table (for the user/group that should have a read-only view without selection capabilies) to NOT have the edit/delete permissions on that table.

Hi pböttcher,

thanks for the reply. That was my hope, but did not work, unfortunately. At least it does not work for anonymous users ("guests").

I have re-checked permissions for anonymous-group in Admin-area:

chrome_2019-07-04_07-22-55.png
chrome_2019-07-04_07-22-55.png (5.17 KiB) Viewed 423 times

I have also re-checked that mass-delete is disabled and print-preview is disabled so that there is not need for AppGini to offer the record-selectors.

AppGini_2019-07-04_07-25-16.png
AppGini_2019-07-04_07-25-16.png (22.63 KiB) Viewed 423 times

But with these settings the checkboxes are visible for anonymous users.

Thanks anyway @pböttcher for taking so much time to help me and others here on the forum!

Best,
Jan

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

Re: AppGini Tableview Quickie: remove record-selector checkboxes

Post by jsetzer » 2019-07-04 05:44

onoehring wrote:
2019-07-04 04:19
Is there a chance to keep them for certain groups? I would know how to do this in php but in the -tv table?
Hi Olaf,

if there is need to check the context in PHP before rendering the page, you can use TABLENAME_header- or TABLENAME_footer-functions in hooks/TABLENAME.php. Add those script-lines depending on the context, for example depending on the currently logged in member's group.

If you need to check the context or any other condition on client side, the commonly used way is:
  1. Write some PHP-file evaluating the conditions and returning the context as JSON. For example check getLoggedMemberID() and return some boolean value.
  2. Then call that PHP-file using one of the $j.ajax() functions in your hooks/TABLENAME-tv.js file.
  3. Depending on the result of the ajax-call, do client-side changes using JavaScript/JQuery, for example hide some elements.
Best,
Jan

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 325
Joined: 2019-05-21 22:42
Contact:

Re: AppGini Tableview Quickie: remove record-selector checkboxes

Post by onoehring » 2019-07-04 05:52

Hi Jan,

thank you for the explanation. I did not think of the possibility to use the code in the _footer function of the table combined with php conditions.
I will try that.

Olaf

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 325
Joined: 2019-05-21 22:42
Contact:

Re: AppGini Tableview Quickie: remove record-selector checkboxes

Post by onoehring » 2019-07-04 06:21

Hi Jan,
pretty neat. It works like a charm ... for the users from the groups I want to (code below). Thank you. Should work for guest as well I believe.

From the hooks for the tablename:

Code: Select all

function my_footer($contentType, $memberInfo, &$args){
		$footer='';
		
		//only for groups with elevated priviliges, I found it useful to set a variable so I can use that for different scenarios later
		if ($memberInfo['group'] != 'Admins' && $memberInfo['group'] != 'AdminsLokale') {				
			$ElevevatedPrivilige = "N";	
		}
		else {
			$ElevevatedPrivilige = "Y";
		}
		
				
		if ($ElevevatedPrivilige == "Y"){
			$NoRecordSelectors = "";
		}
		else{	
			$NoRecordSelectors = "<script>\$j(function(){
			\$j('#order-by-selector').closest('tr').hide().remove()
			\$j('#select_all_records').closest('th').hide().remove()
			\$j('.record_selector').closest('td').hide().remove()
			})</script>";				
			
		}
		
		switch($contentType){
			case 'tableview':
			$footer= $NoRecordSelectors . '<%%FOOTER%%>';			
			break;
			
			case 'detailview':
			$footer= $NoRecordSelectors . '<%%FOOTER%%>';			
			break;
			
			case 'tableview+detailview':
			$footer= $NoRecordSelectors . '<%%FOOTER%%>';			
			break;
			
			case 'print-tableview':
			$footer='';
			break;
			
			case 'print-detailview':
			$footer='';
			break;
			
			case 'filters':
			$footer='';
			break;
		}
		
		return $footer;
	}
Olaf

Post Reply