Page 1 of 1
AppGini Tableview Quickie: remove record-selector checkboxes
Posted: 2019-07-03 17:24
by jsetzer
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 (8.12 KiB) Viewed 6667 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 (6.87 KiB) Viewed 6667 times
KindRegards,
Jan
Re: AppGini Tableview Quickie: remove record-selector checkboxes
Posted: 2019-07-03 21:11
by pbottcher
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.
Re: AppGini Tableview Quickie: remove record-selector checkboxes
Posted: 2019-07-04 04:19
by onoehring
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 (8.26 KiB) Viewed 6650 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
Re: AppGini Tableview Quickie: remove record-selector checkboxes
Posted: 2019-07-04 05:32
by jsetzer
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 (5.17 KiB) Viewed 6647 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 (22.63 KiB) Viewed 6647 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
Re: AppGini Tableview Quickie: remove record-selector checkboxes
Posted: 2019-07-04 05:44
by jsetzer
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:
- Write some PHP-file evaluating the conditions and returning the context as JSON. For example check getLoggedMemberID() and return some boolean value.
- Then call that PHP-file using one of the $j.ajax() functions in your hooks/TABLENAME-tv.js file.
- Depending on the result of the ajax-call, do client-side changes using JavaScript/JQuery, for example hide some elements.
Best,
Jan
Re: AppGini Tableview Quickie: remove record-selector checkboxes
Posted: 2019-07-04 05:52
by onoehring
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
Re: AppGini Tableview Quickie: remove record-selector checkboxes
Posted: 2019-07-04 06:21
by onoehring
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
Re: AppGini Tableview Quickie: remove record-selector checkboxes
Posted: 2020-05-29 14:58
by Jay Webb
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..
Re: AppGini Tableview Quickie: remove record-selector checkboxes
Posted: 2020-05-29 16:22
by Jay Webb
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.
Re: AppGini Tableview Quickie: remove record-selector checkboxes
Posted: 2020-05-31 09:40
by patsd102
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
Re: AppGini Tableview Quickie: remove record-selector checkboxes
Posted: 2020-05-31 10:34
by pbottcher
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;
.....
Re: AppGini Tableview Quickie: remove record-selector checkboxes
Posted: 2020-05-31 12:43
by Jay Webb
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.
Re: AppGini Tableview Quickie: remove record-selector checkboxes
Posted: 2020-05-31 12:52
by pbottcher
Hi,
that you could do by
$footer='<script>$j("td:first-child input").remove();$j("tr th:first input").remove();</script>';
Re: AppGini Tableview Quickie: remove record-selector checkboxes
Posted: 2020-05-31 12:58
by Jay Webb
Sweet, that works as well, that could come in handy for other fields..