Users lookup dropdown list
Users lookup dropdown list
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?
-
- AppGini Super Hero
- Posts: 336
- Joined: 2015-12-23 16:52
Re: Users lookup dropdown list
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:
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.
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=""> </option>
<option value="ANY" >ANY</option>
</select>
<script>jQuery(function(){ jQuery("#suffix").addClass('option_list').select2({ minimumResultsForSearch: 15, width: '90%' }); })</script>
</div>
</div>
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.
Re: Users lookup dropdown list
Thanks very much for your help, grimblefritz. It gives me something to work on.
-
- AppGini Super Hero
- Posts: 336
- Joined: 2015-12-23 16:52
Re: Users lookup dropdown list
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=""> </option>
<option value="ANY" >ANY</option>
</select>
<script>jQuery(function(){ jQuery("#userlist").addClass('option_list').select2({ minimumResultsForSearch: 15, width: '90%' }); })</script>
</div>
</div>
Re: Users lookup dropdown list
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
"
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
Re: Users lookup dropdown list
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?
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?
Re: Users lookup dropdown list
Hello pböttcher,
you can change the select to div
<option value=""> </option>
<option value="ANY" >ANY</option>
<script>jQuery(function(){ jQuery("#userlist").addClass('option_list').select2({ minimumResultsForSearch: 15, width: '90%' }); })</script>
</div>
</div>[/code]
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="ANY" >ANY</option>
Code: Select all
</div>
</div>
</div>[/code]
Re: Users lookup dropdown list
<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=""> </option>
<option value="ANY" >ANY</option>
</select>
<script>jQuery(function(){ jQuery("#userlist").addClass('option_list').select2({ minimumResultsForSearch: 15, width: '90%' }); })</script>
</div>
</div>
<div class="col-lg-9">
<select style="width: 100%;" name="userlist" id="userlist">
<option value=""> </option>
<option value="ANY" >ANY</option>
</select>
<script>jQuery(function(){ jQuery("#userlist").addClass('option_list').select2({ minimumResultsForSearch: 15, width: '90%' }); })</script>
</div>
</div>