Make field read only

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
bescott53
Veteran Member
Posts: 126
Joined: 2013-02-24 00:13

Make field read only

Post by bescott53 » 2018-06-22 12:46

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;
		}
	}


Appgini 5.72

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

Re: Make field read only

Post by pböttcher » 2018-06-22 14:43

Hi,

what kind of field do you try to make readonly. Can you post the code you actually used in your project?

bescott53
Veteran Member
Posts: 126
Joined: 2013-02-24 00:13

Re: Make field read only

Post by bescott53 » 2018-06-22 15:15

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);
                                                                                                                     })
                                                                                             }
});

Appgini 5.72

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

Re: Make field read only

Post by pböttcher » 2018-06-22 15:44

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?

bescott53
Veteran Member
Posts: 126
Joined: 2013-02-24 00:13

Re: Make field read only

Post by bescott53 » 2018-06-22 16:05

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.
Appgini 5.72

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

Re: Make field read only

Post by pböttcher » 2018-06-22 18:09

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);
                                                                                                                     })
                                                                                             }
});

bescott53
Veteran Member
Posts: 126
Joined: 2013-02-24 00:13

Re: Make field read only

Post by bescott53 » 2018-06-25 08:47

Hi, thankyou for this however i can still see this if i am not in the admins group? doesnt appear to work
Appgini 5.72

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

Re: Make field read only

Post by pböttcher » 2018-06-25 10:23

Hi,

sorry, can you try this:

Code: Select all

$j(function () {

                                if($mi['group'] != 'Admins'){
                                                                   $j(#approvedby_so-container').prop("disabled", true);
                                                                   }
});

bescott53
Veteran Member
Posts: 126
Joined: 2013-02-24 00:13

Re: Make field read only

Post by bescott53 » 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);
                                            }
});
Appgini 5.72

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

Re: Make field read only

Post by pböttcher » 2018-06-25 17:46

Hi,
can you post a screenshot of the console view of your field. Maybe the name is not correct.

bescott53
Veteran Member
Posts: 126
Joined: 2013-02-24 00:13

Re: Make field read only

Post by bescott53 » 2018-06-26 09:27

thanks, I have checked the console but it is blank. looked in Dom explorer and saw the attached
attached.png
attached.png (55.86 KiB) Viewed 3059 times
Appgini 5.72

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

Re: Make field read only

Post by pböttcher » 2018-06-26 09:43

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.

bescott53
Veteran Member
Posts: 126
Joined: 2013-02-24 00:13

Re: Make field read only

Post by bescott53 » 2018-06-26 09:54

it is pbottcher. is it due to using a different theme maybe? (still supplied by appgini)
Appgini 5.72

User avatar
a.gneady
Site Admin
Posts: 996
Joined: 2012-09-27 14:46
Contact:

Re: Make field read only

Post by a.gneady » 2018-06-26 10:55

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 }
:idea: Learn all the tips and tricks of customizing AppGini apps through our online course.

:arrow: Summary Reports plugin enables you to build powerful reports and charts inside your AppGini application through a few simple steps. See the big picture and discover trends in your data that empower you to take the right decisions confidently.

:arrow: Search Page Maker enables you to build user-friendly yet powerful search pages for your AppGini application by simply dragging and dropping the fields you want to include in search.

bescott53
Veteran Member
Posts: 126
Joined: 2013-02-24 00:13

Re: Make field read only

Post by bescott53 » 2018-06-26 11:02

thanks Ahmed, but still doesnt work?
Appgini 5.72

User avatar
a.gneady
Site Admin
Posts: 996
Joined: 2012-09-27 14:46
Contact:

Re: Make field read only

Post by a.gneady » 2018-06-26 11:10

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;
	}
}
:idea: Learn all the tips and tricks of customizing AppGini apps through our online course.

:arrow: Summary Reports plugin enables you to build powerful reports and charts inside your AppGini application through a few simple steps. See the big picture and discover trends in your data that empower you to take the right decisions confidently.

:arrow: Search Page Maker enables you to build user-friendly yet powerful search pages for your AppGini application by simply dragging and dropping the fields you want to include in search.

bescott53
Veteran Member
Posts: 126
Joined: 2013-02-24 00:13

Re: Make field read only

Post by bescott53 » 2018-06-26 12:52

I am getting http500 error with this
Appgini 5.72

bescott53
Veteran Member
Posts: 126
Joined: 2013-02-24 00:13

Re: Make field read only

Post by bescott53 » 2018-06-26 13:55

so i removed the last } but it still isn't working although no 500 error now.
Appgini 5.72

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

Re: Make field read only

Post by pböttcher » 2018-06-26 14:52

can you post an image where we can see your field in the appGini application definition and in the Web-GUI.

bescott53
Veteran Member
Posts: 126
Joined: 2013-02-24 00:13

Re: Make field read only

Post by bescott53 » 2018-06-26 16:45

sure , here you go
Attachments
attached.png
attached.png (59.04 KiB) Viewed 3030 times
Appgini 5.72

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

Re: Make field read only

Post by pböttcher » 2018-06-26 19:17

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;
		}
	}

bescott53
Veteran Member
Posts: 126
Joined: 2013-02-24 00:13

Re: Make field read only

Post by bescott53 » 2018-06-27 13:22

nope still no joy!
Appgini 5.72

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

Re: Make field read only

Post by pböttcher » 2018-06-27 14:05

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.

grimblefritz
Veteran Member
Posts: 318
Joined: 2015-12-23 16:52

Re: Make field read only

Post by grimblefritz » 2018-06-27 15:34

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

bescott53
Veteran Member
Posts: 126
Joined: 2013-02-24 00:13

Re: Make field read only

Post by bescott53 » 2018-06-28 12:36

grimblefritz, thank you. i will read through and come back with an update

pböttcher - attached for info
SnipImage.JPG
SnipImage.JPG (128.61 KiB) Viewed 2980 times
Appgini 5.72

Post Reply