How to load external data into view:'select'

Hi, I need to load a list of options into a ‘select’ control from an external data source (xml file or php program). I’ve tried using datatype:‘xml’, url:‘myurl.xml’, but it doesn’t work. An alternative would be to use a load method, but it seems there is not load() for the select control.

Thanks a lot. Juan.

You can use “richselect” in such case

 datatype:'xml', url:'myurl.xml',

will work

Stanislav, many thanks for the answer, but I tried it and couldn’t get it to work. My code says now:

{ view: ‘richselect’, label: ‘Empresa’, id: ‘txtEmpresa’, datatype:‘xml’, url:‘empresas.xml’},

and I’ve tried with two different forms of xml:



1
Empresa 1


2
Empresa 2


3
Empresa 3

and



Empresa 1


Empresa 2


Empresa 3

with no success. :frowning:

The popup of Richselect loads options in List component. By default, List displays “value” property. So, if you do not set options array manually and load items from an external datasource, you need to set item “id” as option key and item “value” as option label.

So, the second format of xml is correct:

Empresa 1 Empresa 2 Empresa 3

However, there was a bug in xml data processing. Please try to use the attached library to solve the issue.
touch.zip (140 KB)

I tried using the new library and it works great. Thanks a lot !!! :smiley:

how I can add the selected attribute ?

how I can add the selected attribute

You can define default value in the richselect config:

{ view: ‘richselect’, label: ‘Empresa’, id: ‘txtEmpresa’, datatype:‘xml’, url:‘empresas.xml’, value:‘2’},