Hi. I'm using SmartClient 12.1 Pro. I think i found a bug in ComboBoxItem. What i did to reproduce it:
1. Open the combobox for the first time
2. Start searching for some value
3. Click on the found value
The result is that it chooses the original value that was before the search on that place. For example: in my first screenshot you can see my original data:

Here my first original record has name !!! 20000000. If i type smth for search like in my second screenshot:

And then try to choose the first found record - Afbryder it will choose the record with the name that was originally in it's place - !!! 20000000:

Here below you can see my code where i create the combobox:
getWorkPackComboBox: function() {
const thiz = this;
let currentInspectionName = "";
return isc.DynamicForm.create({
ID: "inspectionListForm",
canEdit: true,
completeOnEnter: true,
width: 240,
fields: [{
name: "reportCombo",
showTitle: false,
width: 240,
type: "select",
editorType: "ComboBoxItem",
addUnknownValues: false,
textMatchStyle: "substring",
optionDataSource: thiz.getDataSource(),
autoFetchData: false,
valueField: "id",
displayField: "name",
sortField: "name",
redrawOnChange: true,
emptyDisplayValue: currentMessages.selectInspection,
click(form, item) {
if (item.getDisplayValue() === currentMessages.selectInspection || item.getValue() === undefined) {
item.setValue("");
}
item.redraw();
document.styleSheets[0].cssRules[235].style.backgroundImage === 'url("./images/pickers/down.png")' ? thiz.updateComboPicker('url("./images/pickers/up.png")') : thiz.updateComboPicker('url("./images/pickers/down.png")');
item.showPicker();
},
focus(form, item) {
currentInspectionName = item.getDisplayValue() || "";
if (item.getDisplayValue() === currentMessages.selectInspection) {
item.setValue("");
item.showPicker();
}
},
keyPress(item, form, keyName, characterValue) {
if (keyName === "Escape") {
item.setValue(currentInspectionName);
item.blur();
}
},
blur(form, item) {
if (!item.getValue()) {
item.setValue(currentInspectionName);
}
},
changed: function(form, item, value) {
if (value) {
const lastInspectionId = localStorage.getItem("lastInspectionId");
if (!lastInspectionId) {
localStorage.setItem("lastInspectionId", value);
const mainLayout = isc.Canvas.getById("mainLayout");
const oldBottomLayout = isc.Canvas.getById("bottomLayout");
if (oldBottomLayout) {
oldBottomLayout.destroy();
}
const newBottomLayout = isc.BottomLayout.getAppLayout(true);
mainLayout.addMember(newBottomLayout, 1);
}
localStorage.setItem("lastInspectionId", value);
isc.Timer.setTimeout(function() {
const bottomLayout = isc.Canvas.getById("bottomLayout");
if (!bottomLayout) {
isc.Timer.setTimeout(arguments.callee, 50);
return;
}
thiz.setDefaultBarHeight();
const locationTabSet = bottomLayout.getMembers()[0];
locationTabSet.selectTab(0);
const locationTab = locationTabSet.getTab(0);
const locationListGrid = locationTab.pane.members[1];
locationListGrid.fetchData({
searchText: null,
searchTypeString: null,
reportId: value,
});
locationTab.setIcon("[SKINIMG]ListGrid/sort_descending.png");
locationListGrid.selectionUpdated();
checkListGrid.updateFields();
checkListGrid.invalidateCache();
},
100);
}
}
},
],
});
},
Here is the datasource code :
isc.ClassFactory.defineClass("InspectionDataSource", "RestDataSource");
isc.InspectionDataSource.addProperties({
jsonPrefix: null,
jsonSuffix: null,
useHttpProxy: false,
noNullUpdates: false,
cacheAllData: true,
dataFormat: "json",
fields: [{
primaryKey: true,
name: "id",
type: "integer",
},
{
name: "name",
type: "string",
},
{
name: "state",
type: "text",
title: currentMessages.state,
},
],
operationBindings: [{
operationType: "fetch",
dataURL: apiServer + "rest/inspections/active",
requestProperties: {
withCredentials: true,
useSimpleHttp: true,
dataProtocol: "getParams",
useHttpProxy: false,
httpMethod: "GET",
},
},
],
transformRequest: function(dsRequest) {
dsRequest.withCredentials = true;
dsRequest.httpHeaders = {
Authorization: "Bearer " + isc.Auth.getCurrentUser().authToken,
};
return this.Super("transformRequest", arguments);
},
});
Please let me know what can i do to fix the issue.
Thank you in advance.
1. Open the combobox for the first time
2. Start searching for some value
3. Click on the found value
The result is that it chooses the original value that was before the search on that place. For example: in my first screenshot you can see my original data:
Here my first original record has name !!! 20000000. If i type smth for search like in my second screenshot:
And then try to choose the first found record - Afbryder it will choose the record with the name that was originally in it's place - !!! 20000000:
Here below you can see my code where i create the combobox:
getWorkPackComboBox: function() {
const thiz = this;
let currentInspectionName = "";
return isc.DynamicForm.create({
ID: "inspectionListForm",
canEdit: true,
completeOnEnter: true,
width: 240,
fields: [{
name: "reportCombo",
showTitle: false,
width: 240,
type: "select",
editorType: "ComboBoxItem",
addUnknownValues: false,
textMatchStyle: "substring",
optionDataSource: thiz.getDataSource(),
autoFetchData: false,
valueField: "id",
displayField: "name",
sortField: "name",
redrawOnChange: true,
emptyDisplayValue: currentMessages.selectInspection,
click(form, item) {
if (item.getDisplayValue() === currentMessages.selectInspection || item.getValue() === undefined) {
item.setValue("");
}
item.redraw();
document.styleSheets[0].cssRules[235].style.backgroundImage === 'url("./images/pickers/down.png")' ? thiz.updateComboPicker('url("./images/pickers/up.png")') : thiz.updateComboPicker('url("./images/pickers/down.png")');
item.showPicker();
},
focus(form, item) {
currentInspectionName = item.getDisplayValue() || "";
if (item.getDisplayValue() === currentMessages.selectInspection) {
item.setValue("");
item.showPicker();
}
},
keyPress(item, form, keyName, characterValue) {
if (keyName === "Escape") {
item.setValue(currentInspectionName);
item.blur();
}
},
blur(form, item) {
if (!item.getValue()) {
item.setValue(currentInspectionName);
}
},
changed: function(form, item, value) {
if (value) {
const lastInspectionId = localStorage.getItem("lastInspectionId");
if (!lastInspectionId) {
localStorage.setItem("lastInspectionId", value);
const mainLayout = isc.Canvas.getById("mainLayout");
const oldBottomLayout = isc.Canvas.getById("bottomLayout");
if (oldBottomLayout) {
oldBottomLayout.destroy();
}
const newBottomLayout = isc.BottomLayout.getAppLayout(true);
mainLayout.addMember(newBottomLayout, 1);
}
localStorage.setItem("lastInspectionId", value);
isc.Timer.setTimeout(function() {
const bottomLayout = isc.Canvas.getById("bottomLayout");
if (!bottomLayout) {
isc.Timer.setTimeout(arguments.callee, 50);
return;
}
thiz.setDefaultBarHeight();
const locationTabSet = bottomLayout.getMembers()[0];
locationTabSet.selectTab(0);
const locationTab = locationTabSet.getTab(0);
const locationListGrid = locationTab.pane.members[1];
locationListGrid.fetchData({
searchText: null,
searchTypeString: null,
reportId: value,
});
locationTab.setIcon("[SKINIMG]ListGrid/sort_descending.png");
locationListGrid.selectionUpdated();
checkListGrid.updateFields();
checkListGrid.invalidateCache();
},
100);
}
}
},
],
});
},
Here is the datasource code :
isc.ClassFactory.defineClass("InspectionDataSource", "RestDataSource");
isc.InspectionDataSource.addProperties({
jsonPrefix: null,
jsonSuffix: null,
useHttpProxy: false,
noNullUpdates: false,
cacheAllData: true,
dataFormat: "json",
fields: [{
primaryKey: true,
name: "id",
type: "integer",
},
{
name: "name",
type: "string",
},
{
name: "state",
type: "text",
title: currentMessages.state,
},
],
operationBindings: [{
operationType: "fetch",
dataURL: apiServer + "rest/inspections/active",
requestProperties: {
withCredentials: true,
useSimpleHttp: true,
dataProtocol: "getParams",
useHttpProxy: false,
httpMethod: "GET",
},
},
],
transformRequest: function(dsRequest) {
dsRequest.withCredentials = true;
dsRequest.httpHeaders = {
Authorization: "Bearer " + isc.Auth.getCurrentUser().authToken,
};
return this.Super("transformRequest", arguments);
},
});
Please let me know what can i do to fix the issue.
Thank you in advance.
Comment