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: 634
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 2506 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 2506 times

KindRegards,
Jan

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 943
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: 541
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 2489 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
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 634
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 2486 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 2486 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: 634
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: 541
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
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 541
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
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

User avatar
Jay Webb
Veteran Member
Posts: 80
Joined: 2017-08-26 15:27
Contact:

Re: AppGini Tableview Quickie: remove record-selector checkboxes

Post by Jay Webb » 2020-05-29 14:58

Hello Jan

Recently got your JavaScript plugin and there's a lot of great features,
one that i'm using is

Code: Select all

jQuery(function () {
  var url = "marriage_view.php?SelectedID=%ID%";
  var tv = new AppGiniTableView();
  tv.addLink(url, "search", "Open");
});
problem is the checkbox, if I use the code you posted above I lose the button to open,
is there a way to hide just the checkbox but not lose the column, I tried a few different things
but still had adverse effects.

I like having the button to open in detail view.

Thanks for the great plugin addition..
What we envision, we make happen.

User avatar
Jay Webb
Veteran Member
Posts: 80
Joined: 2017-08-26 15:27
Contact:

Re: AppGini Tableview Quickie: remove record-selector checkboxes

Post by Jay Webb » 2020-05-29 16:22

Solved

I found a way with css to display none;
add this to my custom css sheet

Code: Select all

<style>
input[type="checkbox"] {
    display: none;
}
</style>
and sense I'm not using checkbox's anywhere else I ok with it..
css is wonderful.

I you have a better way please post.
What we envision, we make happen.

patsd102
Veteran Member
Posts: 108
Joined: 2013-01-15 19:59

Re: AppGini Tableview Quickie: remove record-selector checkboxes

Post by patsd102 » 2020-05-31 09:40

css remove the check box, but did not remove the table box,

To remove the box as well, in the datalist.php file comment out here:
line 971 //$this->HTML .= "<td class=\"text-center\"><input class=\"hidden-print record_selector\" type=\"checkbox\" id=\"record_selector_{$attr_id}\" name=\"record_selector[]\" value=\"{$attr_id}\"{$checked}></td>";

Just an observation, I tried Jezters method before and the check boxes where visible for a split second each time the page was reloaded

Pat
AppGini Pro V 5.8

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

Re: AppGini Tableview Quickie: remove record-selector checkboxes

Post by pböttcher » 2020-05-31 10:34

Hi,

rather modifying core files, try to use the hooks.

You can try to add to

Code: Select all

	function tablename_footer($contentType, $memberInfo, &$args){
		$footer='';

		switch($contentType){
			case 'tableview':
				$footer='<script>$j("td:first-child").remove();$j("tr th:first").remove();</script>';
				break;

			.....

User avatar
Jay Webb
Veteran Member
Posts: 80
Joined: 2017-08-26 15:27
Contact:

Re: AppGini Tableview Quickie: remove record-selector checkboxes

Post by Jay Webb » 2020-05-31 12:43

Yea learned my lesson changing root files, hooks and custom css files for me, I wanted to keep the field and just remove the check box making room
for my button.
What we envision, we make happen.

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

Re: AppGini Tableview Quickie: remove record-selector checkboxes

Post by pböttcher » 2020-05-31 12:52

Hi,

that you could do by

$footer='<script>$j("td:first-child input").remove();$j("tr th:first input").remove();</script>';

User avatar
Jay Webb
Veteran Member
Posts: 80
Joined: 2017-08-26 15:27
Contact:

Re: AppGini Tableview Quickie: remove record-selector checkboxes

Post by Jay Webb » 2020-05-31 12:58

Sweet, that works as well, that could come in handy for other fields..
What we envision, we make happen.

Post Reply