Announcement

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

    saveData with binary field: callback not fired

    SmartClient Version: v13.1p_2025-03-21/AllModules Development Only (built 2025-03-21)

    Hello, please modify the customBinaryField sample like this:

    Code:
    isc.DynamicForm.create({
        ID: "formView",
        width: "100%",
        dataSource: customBinaryField,
        fields: [
            {name: "id", width: 150, canEdit: false},
            {name: "file", canEdit: false}
        ]
    });
    
    isc.DynamicForm.create({
        ID: "formEdit",
        width: 100,
        dataSource: customBinaryField,
        fields: [
            {name: "id", width: 150, required: true, canEdit: true},
            {name: "title"},
            {
                name: "file", required: true,
                readOnlyWhen: {fieldName: "formEdit.values.file_filename", operator: "notNull"}
            }
        ]
    });
    
    isc.IButton.create({
        ID: "uploadButton",
        title: "Upload",
        width: 100,
        click: function () {
            formEdit.saveData("if(dsResponse.status>=0) formEdit.editNewRecord()");
        }
    });
    
    isc.VLayout.create({
        ID: "vLayoutForms",
        width: 100,
        members: [
            isc.Label.create({
                contents: "Editor",
                width: 50,
                height: 25,
                autoDraw: true,
                baseStyle: "exampleSeparator"
            }),
            formEdit,
            uploadButton,
            isc.Label.create({
                contents: "View",
                width: 50,
                height: 25,
                autoDraw: true,
                baseStyle: "exampleSeparator"
            }),
            formView
        ]
    });
    
    isc.ListGrid.create({
        ID: "listGrid",
        width: 500, height: 224,
        dataSource: customBinaryField,
        selectionType: "single",
        autoFetchData: true,
        fields: [
            {name: "id", width: 100},
            {name: "file", width: 380}
        ],
        recordClick: function (viewer, record, recordNum, field, fieldNum, value, rawValue) {
            formEdit.editSelectedData(listGrid);
            formView.editSelectedData(listGrid);
        }
    });
    
    isc.HLayout.create({
        ID: "hLayoutTop",
        width: 700,
        layoutMargin: 10,
        membersMargin: 10,
        members:[listGrid, vLayoutForms]
    });
    
    isc.Button.create({
        ID: "buttonDownload",
        width: 200,
        title: "Download Selected File",
        click: function () {
            var selectedRecord = listGrid.getSelectedRecord();
            if (selectedRecord == null) {
                isc.say("You must select one record");
                return;
            }
            customBinaryField.downloadFile(selectedRecord);
        }
    });
    
    isc.Button.create({
        ID: "buttonView",
        width: 200,
        title: "View Selected File",
        click: function () {
            var selectedRecord = listGrid.getSelectedRecord();
            if (selectedRecord == null) {
                isc.say("You must select one record");
                return;
            }
            customBinaryField.viewFile(selectedRecord);
        }
    });
    
    
    isc.HLayout.create({
        ID: "hLayoutButtons",
        width: 500,
        layoutMargin: 10,
        membersMargin: 10,
        members: [buttonDownload, buttonView]
    });
    
    isc.VLayout.create({
        ID: "vLayout",
        width: 300,
        members: [hLayoutTop, hLayoutButtons]
    });
    I've added canEdit: true to the "id" field in formEdit, a "title" field to the same form, and a readOnlyWhen condition to the "file" field in the DynamicForm.

    If you enter a new ID, select a file, and press "Upload", you'll notice that after a successful saveData, the callback is not triggered, and a WARN message is logged:

    Code:
    WARN:TabIndexManager:Attempt to move unrecognized target ID:isc_DynamicForm_0

    #2
    Regarding my use case: I have a DynamicForm to add or edit grid's records that include a binary field.
    I use readOnlyWhen so that the file name remains visible when editing (the user might only want to modify other fields).
    Then, I have an icon to make it editable if the user actually wants to upload a different file.

    Comment


      #3
      Hello, may I ask if you see any problem here, or if I'm missing something obvious?

      Comment

      Working...
      X