I have been fighting a dependent combobox issue for a while. Everything seems to work during new item entry but the dependent combo query is not correct for a fetchData() call. The parent's key is not being used for the secondary combo query. I put together a small test of this issue as follows:
I separated the minorValuesDS DataSource data into a separate file (minors.json) so I could watch the query string using FireBug:
To test just press the Edit Existing Item button. According to FireBug, the query on minorValuesDS includes just the "minor" field value. If getPickListFilterCriteria was called an alert would be displayed and the "major" value would be included as well.
To see the proper query, press New Item button, select a major and then select a minor:
In this case we don't yet have a minor value to be part of the query but the major was included and the alert displayed.
Is this a bug or am I missing something key?
Thanks!
Code:
isc.DataSource.create({
ID: "itemHeaderDS",
dataFormat: "json",
title: "Item",
fields: [
{
name: "itemId",
title: "Item ID",
type: "text",
primaryKey: true,
required: true,
length: 30
},
{
name: "itemDesc",
title: "Description",
type: "text",
required: true,
length: 30
},
{
name: "major",
title: "Major",
type: "text",
required: true,
length: 4,
foreignKey: "majorValuesDS.major"
},
{
name: "minor",
title: "Minor",
type: "text",
required: true,
length: 4,
foreignKey: "minorValuesDS.minor"
}
],
clientOnly: true,
testData: [
{ itemId: "143560", itemDesc: "A test item", major: "TOYO", minor: "M101"}
]
})
isc.RestDataSource.create({
ID: "majorValuesDS",
dataFormat: "json",
title: "Majors",
fields: [
{
name: "major",
title: "Major",
type: "text",
primaryKey: true,
canEdit: false,
length: 4
},
{
name: "description",
title: "Description",
type: "text",
canEdit: false,
length: 30
}
],
clientOnly: true,
testData: [
{ major:"AS", description:"ARMSTRONG" },
{ major:"FS", description:"FIRESTONE" },
{ major:"TOYO", description:"TOYO" }
]
})
isc.DataSource.create({
ID: "minorValuesDS",
dataFormat: "json",
dataURL: "/minors.json",
title: "Minors",
fields: [
{
name: "PK_minorValuesDS",
title: "PrimaryKey",
type: "text",
primaryKey: true,
length: 256,
hidden: true
},
{
name: "minor",
title: "Minor",
type: "text",
canEdit: false,
length: 4
},
{
name: "major",
title: "Major",
type: "text",
canEdit: false,
length: 4
},
{
name: "description",
title: "Description",
type: "text",
canEdit: false,
length: 30
}
]
})
isc.DynamicForm.create({
width: 500,
numCols: 4,
autoFocus: true,
dataSource: "itemHeaderDS",
fields: [
{name: "itemId"},
{name: "itemDesc"},
{name: "major", title: "Major", editorType: "ComboBoxItem", type: "select", width: "*",
optionDataSource:"majorValuesDS",
allowEmptyValue: true,
valueField:"major",
displayField:"description",
showPickListOnKeypress: true,
completeOnTab: true,
changed: function (form, item, value) {
var field = form.getField('minor');
field.setValue(null);
field.setDisabled(!value);
},
pickListWidth:450,
pickListFields: [
{ name:"major", width: 50 },
{ name:"description" }
] },
{name: "minor", title: "Minor", editorType: "ComboBoxItem", type: "select", width: "*",
optionDataSource:"minorValuesDS",
autoFetchData: false,
allowEmptyValue: true,
disabled: true,
valueField:"minor",
displayField:"description",
showPickListOnKeypress: true,
completeOnTab: true,
pickListWidth:450,
pickListFields: [
{ name:"minor", width: 50 },
{ name:"description" }
],
getPickListFilterCriteria : function () {
isc.warn('getPickListFilterCriteria');
return {
major: this.form.getValue("major"),
minor: this.form.getValue("minor")
}
} },
{name: "editBtn", title: "Edit Existing Item", type: "button", click: "this.form.editItem(form)" },
{name: "newBtn", title: "New Item", type: "button", click: "this.form.editNewRecord()" }
],
editItem : function (form) {
form.fetchData();
var field = form.getField('minor');
field.setDisabled(false);
}
});
Code:
[
{ PK_minorValuesDS:"AS/RR1", major:"AS", minor:"RR1", description:"RADIAL1" },
{ PK_minorValuesDS:"AS/RR2", major:"AS", minor:"RR2", description:"RADIAL2" },
{ PK_minorValuesDS:"FS/LT", major:"FS", minor:"LT", description:"LIGHT TRUCK" },
{ PK_minorValuesDS:"FS/TRK", major:"FS", minor:"TRK", description:"TRUCK" },
{ PK_minorValuesDS:"TOYO/HT", major:"TOYO", minor:"HT", description:"HT" },
{ PK_minorValuesDS:"TOYO/M101", major:"TOYO", minor:"M101", description:"M101" }
]
Code:
From FireBug: GET http://localhost:8080/minors.json?minor=M101 (22ms)
Code:
GET http://localhost:8080/minors.json?major=FS (220ms)
Is this a bug or am I missing something key?
Thanks!
Comment