Hello, I am currently trying to create a combobox of the contacts associated with a certain account. When a contact is selected, then that contact will be made the primary contact.
Everything works fine, but when the edit page first launches the combobox does not display the primary contact and appears as it does below.
How would I get the combobox to display the primary contact on initialization like below.
Here is my replacing client schema:
define("AccountPageV2", [],function() {
return {
entitySchemaName: "Account",
details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
attributes: {
"myEnum": {
"dataValueType": Terrasoft.DataValueType.ENUM,
"type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
"caption": "Primary Contact:"
},
"myList": {
"dataValueType": Terrasoft.DataValueType.ENUM,
"type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
"isCollection": true
}
},
diff: /**SCHEMA_DIFF*/[
{
"operation": "insert",
"name": "myEnum",
"values": {
"caption": "myEnum",
"dataValueType": this.Terrasoft.DataValueType.ENUM,
"bindTo": "myEnum",
"layout": { "colSpan": 24, "rowSpan": 1, "column": 0, "row": 4 },
"controlConfig": {
"className": "Terrasoft.ComboBoxEdit",
"list": {
"bindTo": "myList"
},
"change": {
"bindTo": "onMyValueChange"
},
"prepareList": {
"bindTo": "prepareMyList"
}
}
},
"parentName": "SolutionTab_gridLayout",
"propertyName": "items",
"index": 1
}
]/**SCHEMA_DIFF*/,
methods: {
onPageInitialized: function(callback, scope) {
if (!this.get("myList")) {
this.set("myList", this.Ext.create("Terrasoft.Collection"));
}
if (callback) {
callback.call(scope || this);
}
},
onEntityInitialized: function() {
this.callParent(arguments);
},
prepareMyList: function(filter, list) {
if (list === null) {
return;
}
list.clear();
// create query for server side
var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
rootSchemaName: "Contact"
});
esq.addColumn("Name", "Name");
esq.addColumn("Id", "Id");
esq.addColumn("Account.Id","Account");
esq.addColumn("Job.Name","Job");
// run query
var filterAccountType = esq.createColumnFilterWithParameter(
Terrasoft.ComparisonType.EQUAL, "Account", this.get("Id"));
esq.filters.addItem(filterAccountType);
esq.getEntityCollection(function(result) {
//perform
if (!result.success) {
/* For example, error processing/logging. */
this.showInformationDialog("Data query error");
return;
}
var count = 0;
var items = {};
result.collection.each(function (item) {
items[item.get("Id")] = {
"value": item.get("Id"),
"displayValue": item.get("Name")+ " : " + item.get("Job")
};
});
var list = this.get("myList");
list.loadAll(items);
}, this);
},
onMyValueChange: function(val) {
if (val) {
console.log("New Primary Contact Added");
this.set('PrimaryContact',val);
}
}
},
rules: {}
};
});