Page 1 of 3
Make field read only
Posted: 2018-06-22 12:46
by bescott53
Ahmed, I have used the code you have on the support pages below to make a field read only but it does not seem to work, can you help?
http://bigprof.com/appgini/help/advance ... ter_update
Code: Select all
function tablename_dv($selectedID, $memberInfo, &$html, &$args){
/* current user is not an admin? */
if($mi['group'] != 'Admins'){
$html .= <<<EOC
<script>
\$j(function(){
\$j('#price').prop('readonly', true);
})
</script>
EOC;
}
}
Re: Make field read only
Posted: 2018-06-22 14:43
by pbottcher
Hi,
what kind of field do you try to make readonly. Can you post the code you actually used in your project?
Re: Make field read only
Posted: 2018-06-22 15:15
by bescott53
sure, i moved this on though. i created a file in the hooks folder called "commission_approval-dv.js" and then pasted this into it
Code: Select all
$j(function () {
if($mi['group'] != 'Admins'){
$j(function(){
$j('#approvedby_so').prop('readonly', true);
})
}
});
Re: Make field read only
Posted: 2018-06-22 15:44
by pbottcher
ok, so what type of field is the #approvedby_so ? is it a text field or a selection.
Also did you check that your user is not part of the admins group?
Re: Make field read only
Posted: 2018-06-22 16:05
by bescott53
thanks pbottcher, it is a selection, blank by default with the option of yes or no or blank. the person is not in the admins group as only i am in that.
Re: Make field read only
Posted: 2018-06-22 18:09
by pbottcher
Hi,
in case you have a selection field you need to apply the following instead the prop:
Code: Select all
$j(function () {
if($mi['group'] != 'Admins'){
$j(function(){
$j(#approvedby_so-container').attr('disabled', true);
})
}
});
Re: Make field read only
Posted: 2018-06-25 08:47
by bescott53
Hi, thankyou for this however i can still see this if i am not in the admins group? doesnt appear to work
Re: Make field read only
Posted: 2018-06-25 10:23
by pbottcher
Hi,
sorry, can you try this:
Code: Select all
$j(function () {
if($mi['group'] != 'Admins'){
$j(#approvedby_so-container').prop("disabled", true);
}
});
Re: Make field read only
Posted: 2018-06-25 14:42
by bescott53
not having any luck with this at all.
Code: Select all
$j(function () {
if($mi['group'] != 'Admins'){
$j('#approvedby_so-container').prop("disabled", true);
}
});
Re: Make field read only
Posted: 2018-06-25 17:46
by pbottcher
Hi,
can you post a screenshot of the console view of your field. Maybe the name is not correct.
Re: Make field read only
Posted: 2018-06-26 09:27
by bescott53
thanks, I have checked the console but it is blank. looked in Dom explorer and saw the attached
- attached.png (55.86 KiB) Viewed 12464 times
Re: Make field read only
Posted: 2018-06-26 09:43
by pbottcher
Hi,
this looks strange. Is this a select2 dropdown created by appGini? I cannot see the approvedby_so id in the screenshot. Can you doublecheck.
Re: Make field read only
Posted: 2018-06-26 09:54
by bescott53
it is pbottcher. is it due to using a different theme maybe? (still supplied by appgini)
Re: Make field read only
Posted: 2018-06-26 10:55
by a.gneady
bescott53 wrote: ↑2018-06-25 14:42
not having any luck with this at all.
Code: Select all
$j(function () {
if($mi['group'] != 'Admins'){
$j('#approvedby_so-container').prop("disabled", true);
}
});
Just wish to make a small correction to the code above as it's mixing PHP syntax with JavaScript code ... I didn't test the code below but give it a try and let's see how it goes:
Code: Select all
if($mi['group'] != 'Admins'){ ?>
<script>
$j(function () {
$j('#approvedby_so-container').prop("disabled", true);
});
</script>
<?php }
Re: Make field read only
Posted: 2018-06-26 11:02
by bescott53
thanks Ahmed, but still doesnt work?
Re: Make field read only
Posted: 2018-06-26 11:10
by a.gneady
Hi bescott ... OK, referring to the code at the top of the thread, try this:
Code: Select all
function tablename_dv($selectedID, $memberInfo, &$html, &$args){
/* current user is not an admin? */
if($mi['group'] != 'Admins'){
$html .= <<<EOC
<script>
\$j(function(){
\$j('#approvedby_so-container').prop('disabled', true);
})
</script>
EOC;
}
}
Re: Make field read only
Posted: 2018-06-26 12:52
by bescott53
I am getting http500 error with this
Re: Make field read only
Posted: 2018-06-26 13:55
by bescott53
so i removed the last } but it still isn't working although no 500 error now.
Re: Make field read only
Posted: 2018-06-26 14:52
by pbottcher
can you post an image where we can see your field in the appGini application definition and in the Web-GUI.
Re: Make field read only
Posted: 2018-06-26 16:45
by bescott53
sure , here you go
Re: Make field read only
Posted: 2018-06-26 19:17
by pbottcher
ok, do it is an option list. Can you remove the "-container" and try again.
Code: Select all
function commision_approvals_dv($selectedID, $memberInfo, &$html, &$args){
/* current user is not an admin? */
if($memberinfo['group'] != 'Admins'){
$html .= <<<EOC
<script>
\$j(function(){
\$j('#approvedby_so').prop('disabled', true);
})
</script>
EOC;
}
}
Re: Make field read only
Posted: 2018-06-27 13:22
by bescott53
nope still no joy!
Re: Make field read only
Posted: 2018-06-27 14:05
by pbottcher
can you pls post where you put the code and the code you have pls.
I just saw that there is a typo in the commision above. It should of course be commission.
Re: Make field read only
Posted: 2018-06-27 15:34
by grimblefritz
I worked on this issue some time ago and reached a pretty good solution.
Start with the post below. Then follow the link within it to the main post.
https://forums.appgini.com/phpbb/viewto ... 6518#p6255
Re: Make field read only
Posted: 2018-06-28 12:36
by bescott53
grimblefritz, thank you. i will read through and come back with an update
pböttcher - attached for info
- SnipImage.JPG (128.61 KiB) Viewed 12385 times