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: 1807
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 6664 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 6664 times

KindRegards,
Jan
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 24.10 Revision 1579 + all AppGini Helper tools

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: AppGini Tableview Quickie: remove record-selector checkboxes

Post by pbottcher » 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.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
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 6647 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: 1807
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 6644 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 6644 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
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 24.10 Revision 1579 + all AppGini Helper tools

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
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
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 24.10 Revision 1579 + all AppGini Helper tools

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
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

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
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

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: 142
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
23.17

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: AppGini Tableview Quickie: remove record-selector checkboxes

Post by pbottcher » 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;

			.....
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

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.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: AppGini Tableview Quickie: remove record-selector checkboxes

Post by pbottcher » 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>';
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

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