Users lookup dropdown list

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
bruceholt
Posts: 19
Joined: 2016-07-30 20:16

Users lookup dropdown list

Post by bruceholt » 2016-07-30 20:26

I am trying to create a task assignment app but need to choose users from a dropdown list from the members table (not an additional addon table) and assign the task to them. I am not sure if this is possible using hooks or by some other method and if the permissions for accessing that table could be a problem. Has anyone managed to do this or knows how to do it?

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

Re: Users lookup dropdown list

Post by grimblefritz » 2016-08-09 15:02

You could create a field using the "Options list" tab. Enter bogus data for the options. That will result in a standard HTML <select> being generated.

Then, use jquery in the tablename_dv() hook to modify the <select> <option>s.

For instance, this is an example of the <select> code AG outputs, for a field 'userlist', not required, one option of ANY:

Code: Select all

<div class="form-group">
	<label for="userlist" class="control-label col-lg-3">Suffix</label>
	<div class="col-lg-9">
		<select style="width: 100%;" name="userlist" id="suffix">
			<option value="">&nbsp;</option>
			<option value="ANY" >ANY</option>
		</select>
		<script>jQuery(function(){ jQuery("#suffix").addClass('option_list').select2({ minimumResultsForSearch: 15, width: '90%' }); })</script>
	</div>
</div>
Your hook would need to fetch the users from the members table, then create the <option> tags, and then use jquery to replace (or append to) the <option> list generated by AG.

That's one way. Probably the simplest way. But, if you have a lot of users, then you might want to look into how to modify a regular lookup field, which is done using the select2 js library. Not as easy, but creates a much better user interface.

bruceholt
Posts: 19
Joined: 2016-07-30 20:16

Re: Users lookup dropdown list

Post by bruceholt » 2016-08-10 07:53

Thanks very much for your help, grimblefritz. It gives me something to work on.

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

Re: Users lookup dropdown list

Post by grimblefritz » 2016-08-10 11:06

I should have finished cleaning up the code before posting. Here's a clean example.

Code: Select all

<div class="form-group">
   <label for="userlist" class="control-label col-lg-3">User List</label>
   <div class="col-lg-9">
      <select style="width: 100%;" name="userlist" id="userlist">
         <option value="">&nbsp;</option>
         <option value="ANY" >ANY</option>
      </select>
      <script>jQuery(function(){ jQuery("#userlist").addClass('option_list').select2({ minimumResultsForSearch: 15, width: '90%' }); })</script>
   </div>
</div>

jsinason
Posts: 2
Joined: 2017-02-11 03:16

Re: Users lookup dropdown list

Post by jsinason » 2017-02-14 13:35

Can you explain what you mean by

"
Your hook would need to fetch the users from the members table, then create the <option> tags, and then use jquery to replace (or append to) the <option> list generated by AG.
"

thanks

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

Re: Users lookup dropdown list

Post by pböttcher » 2018-04-12 21:28

Hi,
I tried to get this working, but am failling due to the error:
ajax' is not allowed for Select2 when attached to a <select>
when I try to have the data for the selection box polled via ajax.

Any ideas how to reslove this?

R Tammam
Veteran Member
Posts: 113
Joined: 2017-08-26 15:35

Re: Users lookup dropdown list

Post by R Tammam » 2018-04-18 14:06

Hello pböttcher,
you can change the select to div

Code: Select all

 <label for="userlist" class="control-label col-lg-3">User List</label>
   <div class="col-lg-9">
  [code]    <div style="width: 100%;" name="userlist" id="userlist">
<option value="">&nbsp;</option>
<option value="ANY" >ANY</option>

Code: Select all

    </div>
<script>jQuery(function(){ jQuery("#userlist").addClass('option_list').select2({ minimumResultsForSearch: 15, width: '90%' }); })</script>
</div>
</div>[/code]

R Tammam
Veteran Member
Posts: 113
Joined: 2017-08-26 15:35

Re: Users lookup dropdown list

Post by R Tammam » 2018-04-18 14:06

<label for="userlist" class="control-label col-lg-3">User List</label>
<div class="col-lg-9">
<select style="width: 100%;" name="userlist" id="userlist">
<option value="">&nbsp;</option>
<option value="ANY" >ANY</option>
</select>
<script>jQuery(function(){ jQuery("#userlist").addClass('option_list').select2({ minimumResultsForSearch: 15, width: '90%' }); })</script>
</div>
</div>

Post Reply