Announcement

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

    ComboBoxItem client‑side filter picks wrong record on click when loading data first time.

    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:
    Click image for larger version

Name:	step 1.png
Views:	19
Size:	18.1 KB
ID:	275550
    Here my first original record has name !!! 20000000. If i type smth for search like in my second screenshot:
    Click image for larger version

Name:	step 2.png
Views:	12
Size:	20.0 KB
ID:	275551
    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:
    Click image for larger version

Name:	step 3.png
Views:	12
Size:	1.4 KB
ID:	275552

    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.



    #2
    This looks like a possible bug in your application code, not the ComboBoxItem.

    If you think it's a bug in the framework, please create a ready-to-run, standalone test case demonstrating the problem.

    Note also:
    1. you always need to post your full version (with build date) and always need to test against the latest patched version (see smartclient.com/builds)
    2. use "CODE" tags around code to preserve indentation

    Comment

    Working...
    X