EasyUI Forum
April 29, 2024, 01:19:04 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Problem with combobox getValue  (Read 1340 times)
galcott
Newbie
*
Posts: 39


View Profile
« 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.


And this shows the result of 'getValue' which is actually the same as 'getText'). Why is 'getValue' returning the valueField?
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 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"}
]
Logged
galcott
Newbie
*
Posts: 39


View Profile
« Reply #2 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.

Can you tell me any possible reason why this would happen? I've tested this a lot and can't figure it out.
« Last Edit: February 08, 2023, 12:49:21 PM by galcott » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #3 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.
Logged
galcott
Newbie
*
Posts: 39


View Profile
« Reply #4 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?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!