Appframe Knowledge Base


1 hits
0

Binding ComboBox in a form to show items from a custom data object

// For how to define an array data object, see: http://kb.omega.no/kb/1240

// For this to work properly, the field must be defined without LookupID and ListBoxID
// in the form panel designer in the app designer.

// Get a reference to the field
var vMyField = formMain.getFields("IssueType");

// Define the ComboBox instance and pass in the data object
vMyField.comboBox = new af.controls.ComboBox({
    input: vMyField.getInput(),
    limitToList: true,
    dropdown: af.controls.DropdownList,
    dataObject: vDataObject,
    displayMember: "Type",
    valueMember: "Type",
    clearable: false
});

// Push the selected value into the form's data object, or call the form's callback
vMyField.comboBox.attachEvent("onValueChanged", function (pValue) {
    if (vMyField.validDataObjectField) {
        vDO.currentRow(vMyField.data.FieldName, pValue);
    } else if (typeof vMyField.callback === "function") {
        vMyField.callback();
    }
});

// Makes the ComboBox not broken
$(vMyField.getInput()).attr("type", "afComboBox");

components web · Perma link post comment Posted by: Jan Henrik H. Meling (13-nov-2013)