Page 1 of 1

Appgini 5.30 Dropdown List Empty

Posted: 2014-11-23 16:43
by wolkenlos
Hi!
I have some problems with the function "Drop-down list". I made a table with 2 values. In the website view the dropdown list is empty. Please take a look at my picture. How to set the first value of the list as default.

regards
wolkenlos

Re: Appgini 5.30 Dropdown List Empty

Posted: 2014-11-23 17:12
by udayvatturi
Hi,
You can use magic hooks and select the default value you want.
Magic Hooks is a javascript file with name same as tablename-dv.js

You select default value, you can use the following code

Newer versions of AppGini (5.20 and above)

Code: Select all

$("#e8").select2("val", "CA");
where e8 is the ID of the container of the drop down (for AppGini apps, the ID is fieldname-container, where fieldname is the name of the drop-down field), "CA" is the new value. So, the code should be:

Code: Select all

jQuery("#fieldname-container").select2("val", "new-value");

Re: Appgini 5.30 Dropdown List Empty

Posted: 2014-11-23 17:32
by wolkenlos
Hi!
Thx for the answer.
I am sorry i am not a coder :-)
where have I put this file: tablename-dv.js (path) - name of my tablename or exactly "tablename-dv.js"
my 2 values are: FEM;;DIN
what have I to code into the file to have a dropdown list with the default value "FEM" first"

I have more dropdownlists.... how to fix it?
also working with: tablename-dv.js

THX A LOT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

greets
wolkenlos

Re: Appgini 5.30 Dropdown List Empty

Posted: 2014-11-23 17:38
by udayvatturi
You are welcome
Please go through this
http://bigprof.com/appgini/help/advance ... agic-files

And coming to

Code: Select all

jQuery("#fieldname-container").select2("val", "new-value");
You need to page and go to inspect element for the dropdown and you find id="XXXX-container"
so you will replace fieldname-continer with xxxx-container
and new-value with "FEM"

Re: Appgini 5.30 Dropdown List Empty

Posted: 2014-11-23 18:18
by wolkenlos
hi udayvatturi!

a little bit more help please :-)

for example I made a new database with 2 tables
1 textfield
1 dropdown

Tablename: table1
Name of the dropdown: field3
2 Values: Peter;;Mary

Name of the conatiner (HTML view):
<div class="panel-body" id="table1_dv_container">

Code: Select all

<div class="row">
		<!-- form inputs -->
		<div class="col-md-8 col-lg-10" id="table1_dv_form">
			<fieldset class="form-horizontal">

				<div class="form-group">
					<label for="field2" class="control-label col-lg-3">Field 2</label>
					<div class="col-lg-9">
						<input tabindex="1" maxlength="40" type="text" class="form-control" name="field2" id="field2" value="" required>
					</div>
				</div>

				<div class="form-group">
					<label for="field3" class="control-label col-lg-3">field3</label>
					<div class="col-lg-9">
						<select tabindex="1" style="width: 100%;" name="field3" id="field3">
	<option value="">&nbsp;</option>
	<option value="Peter" >Peter</option>
	<option value="Mary" >Mary</option></select><script>jQuery(function(){ jQuery("#field3").select2({ minimumResultsForSearch: 15 }); })</script>
					</div>
				</div>

			</fieldset>
		</div>
now I made a file: table1-dv.js

Code: Select all

    $("#table1_dv_container").select2("val", "Peter");
	jQuery("#table1_dv_container").select2("val", "Peter");
I uploaded this file to: /hooks

but I am sorry it dont work.... no effect ;-)

greets
wolkenlos

Re: Appgini 5.30 Dropdown List Empty

Posted: 2014-11-23 21:33
by Bertv
Wolkenlos,
its much easier:
- fill the first value of the possible values into 'Default': FEM
and generate. That's all.

Re: Appgini 5.30 Dropdown List Empty

Posted: 2014-11-24 08:46
by udayvatturi
Yes, that a simple process, how did i missed it. :?:

Re: Appgini 5.30 Dropdown List Empty

Posted: 2014-11-24 16:54
by wolkenlos
Hallo Bertv and Udayvatturi!

Thank you very very much!
I changed the default value and BINGO it worked :-)

greets
wolkenlos