EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: galcott on February 03, 2023, 08:36:17 AM



Title: Problem with combobox getValue
Post by: galcott on February 03, 2023, 08:36:17 AM
I am using a combobox populated from a database using this code. So when I use the 'getValue' method I assume I should get the valueField, not the textField. But I am getting the textField and can't seem to find any way to get the valueField.
Code:
<INPUT class='easyui-combobox' ID='selMaterial' editable=false label='Material' labelWidth=80 style='width: 350px'
   data-options="valueField: 'code', textField: 'name', method: 'get', url: 'sql_main.php?proc=get_materials_select'">
This shows the data in the combobox, using the 'getData' method.
(https://galcott.com/comfitdemo/easyui1.jpg)

And this shows the result of 'getValue' which is actually the same as 'getText'). Why is 'getValue' returning the valueField?
(https://galcott.com/comfitdemo/easyui2.jpg)


Title: Re: Problem with combobox getValue
Post by: jarry on February 04, 2023, 07:29:41 PM
Please make sure the data format returned from your server should be:
Code:
[
{"code":"code1","name":"name1"},
{"code":"code2","name":"name2"},
{"code":"code3","name":"name3"},
{"code":"code4","name":"name4"}
]


Title: Re: Problem with combobox getValue
Post by: galcott on February 08, 2023, 12:27:53 PM
Yes, that is data format from the server. Here it is.
Code:
[ { "code": "", "name": ""},{ "code": "A1", "name": "A1 - COMFORTLITE EVA"},{ "code": "A3", "name": "A3 - SOFTFIT - EVA"},
{ "code": "A4", "name": "A4 - SOFTFIT - PORON"},{ "code": "A5", "name": "A5 - SOFTFIT - CORK"},
{ "code": "A6", "name": "A6 - COMFORTLITE PORON"},{ "code": "A7", "name": "A7 - COMFORTLITE CORK"},
{ "code": "C6", "name": "C6 - CORK UNIBODY"},{ "code": "C7", "name": "C7 - CORK DUAL DENSITY"},
{ "code": "D1", "name": "D1 - DRESSFIT"},{ "code": "D2", "name": "D2 - SLIM-FIT"},{ "code": "D4", "name": "D4 - CASUALFIT"},
{ "code": "D5", "name": "D5 - CASUALFIT PLUS"},{ "code": "DL", "name": "DL - DIABETICFIT FLEXIBLE"},
{ "code": "DR", "name": "DR - DIABETICFIT RIGID"},{ "code": "F1", "name": "F1 - THE CONTROLLER"},
{ "code": "F2", "name": "F2 - UCBL"},{ "code": "F3", "name": "F3 - GAIT PLATE - Correct Intoe"},
{ "code": "F4", "name": "F4 - GAIT PLATE - Correct Outoe"},{ "code": "F5", "name": "F5 - ADULT CONTROLLER"},
{ "code": "F6", "name": "F6 - ADULT UCBL"},{ "code": "L1", "name": "L1 - LEATHER LAMINATE"},
{ "code": "L2", "name": "L2 - LEATHER CORK"},{ "code": "L3", "name": "L3 - LEATHER EVA"},
{ "code": "L5", "name": "L5 - LEATHER PORON"},{ "code": "L6", "name": "L6 - LEATHER SHAFFER"},
{ "code": "L7", "name": "L7 - LEATHER BALANCER "},{ "code": "S1", "name": "S1 - SPORTFIT 3mm"},
{ "code": "S10", "name": "S10 - SPORTFIT 4mm"},{ "code": "S2", "name": "S2 - SPORTFIT PLUS"},
{ "code": "S3", "name": "S3 - COMFORTFLEX"},{ "code": "S4", "name": "S4 - GRAPHLITE I - Moderate"},
{ "code": "S5", "name": "S5 - GRAPHLITE II - Semi-Rigid"},{ "code": "S6", "name": "S6 - GRAPHLITE III - Rigid"},
{ "code": "S7", "name": "S7 - SPORTFIT FLEX"}]

I found that this problem actually occurs in two of the three functions where I use this combobox. In the other one the 'getValue' works correctly. Here is a screen shot showing the result when it works correctly, which as you can see is different from the previous screen shot.
(http://galcott.com/comfitdemo/easyui3.jpg)
Can you tell me any possible reason why this would happen? I've tested this a lot and can't figure it out.


Title: Re: Problem with combobox getValue
Post by: jarry on February 08, 2023, 06:49:29 PM
If the text on the combobox is modified manually, it may not find any data item that matches the inputing text and then this inputing text is accepted as the value.
Please try to set the 'limitToList' property to true to let the combobox only accept the data list item.


Title: Re: Problem with combobox getValue
Post by: galcott on February 08, 2023, 09:44:32 PM
The text is not being modified manually. I'm simply selecting it by clicking on the list, and limitToList is set to true.

I really can't figure out what's happening here. It's actually happening on two different comboboxes, but I have others, also populated from a database, where it works correctly.

Do you have any other ideas?