Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Simple fetch data into String or parse JSON or maybe how to iterate on DataSource?

    SmartClient Version: v8.3_2012-11-20/LGPL Development Only (built 2012-11-20)

    Hello,
    I was trying to do apply ComboBoxItem validation functionality into TextItem. Giving DataSource into ComboBoxItem it acts like to have IsOneOfValidator. FormItem autovalidates to have value specified in dataSource.
    I want only to have that validation without PickList and autocomplete.
    My DataSource is:
    Code:
    public class SupervisorIdsDataSource extends DataSource {
        private static String TARGET_URL = "ds/get_supervisors";
        private static String DS_ID = "SUPERVISORS_DS";
        private static SupervisorIdsDataSource instance = null;
        private SupervisorIdsDataSource(String id) {
            super(id);
            setDataFormat(DSDataFormat.JSON);
            setDataURL(TARGET_URL);
            DataSourceIntegerField field = new DataSourceIntegerField(BasicDataFieldNames.SUPERVISOR_ID);
            setClientOnly(true);
            setFields(field);
            setCacheAllData(true);
        }
        public static SupervisorIdsDataSource getInstance(){
            if (instance == null) {
                instance = new SupervisorIdsDataSource(DS_ID);
            }
            return instance;
        }
    }
    and "ds/get_supervisors" is:
    Code:
    [
        {supervisorId: 100000},
        {supervisorId: 120000},
        {supervisorId: 134000},
        {supervisorId: 145220},
        {supervisorId: 524520}
    ]
    Maybe other aproach exists ? How to add IsOneOfValidator to TextItem fetching JSON data from server?

    PS. Curently I dont use any WebServices but only hardcoded static files to prepare proof of concept that this technology (SmartGWT) meets my client needs.
    Last edited by bartosak; 27 Jan 2013, 12:08. Reason: code formating
Working...
X