Announcement

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

    saveData callback called twice after saving a file

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

    Hi, please try this test case (I've modified the FSupload sample with a log message in the saveData callback):

    Code:
    var firstTime = true;
    
    isc.DynamicForm.create({
        autoDraw: false,
        ID: "uploadForm", width: 300,
        dataSource: mediaLibrary,
        fields: [
            { name: "title", required: true },
            { name: "image", type: "imageFile", multiple:false, hint: "Maximum file size is 5 MiB" },
            { title: "Save", type: "button",
                click: function () {
                    this.form.saveData("isc.logEcho('save callback');if(dsResponse.status>=0) uploadForm.editNewRecord()");
                }
            }
        ]
    });
    
    isc.DynamicForm.create({
        autoDraw: false,
        ID: "searchForm",
        width: "100%",
        numCols: 3,
        colWidths: [60, 200, "*"],
        saveOnEnter:true,
        fields: [
            { name: "title", title: "Title", type: "text", width: "*" },
            { name: "search", title: "Search", type: "SubmitItem",
                startRow: false, endRow: false
            }
        ],
        submit : function () {
            mediaTileGrid.fetchData(this.getValuesAsCriteria(), null, {textMatchStyle:"substring"});
        }
    });
    
    isc.IButton.create({
        autoDraw: false,
        ID: "viewAsTiles",
        title: "View as Tiles",
        autoFit: true,
        icon: "[ISO_DOCS_SKIN]/images/silkicons/application_view_tile.png",
        value: true,
        radioGroup: "views",
        actionType: "checkbox",
        click: function(){
            showTileGrid();
        }
    });
    
    isc.IButton.create({
        autoDraw: false,
        ID:"viewAsList",
        title: "View as List",
        autoFit: true,
        icon: "[ISO_DOCS_SKIN]/images/silkicons/application_view_detail.png",
        radioGroup: "views",
        actionType: "checkbox",
        click: function(){
            showListGrid();
        }
    });
    
    isc.HLayout.create({
        autoDraw: false,
        ID: "buttons",
        width: 500,
        membersMargin: 5,
        padding: 5,
        members: [viewAsTiles, viewAsList]
    });
    
    isc.TileGrid.create({
        autoDraw: false,
        ID: "mediaTileGrid",
        width: "100%",
        height: 224,
        tileWidth: 100,
        tileHeight: 150,
        dataSource: mediaLibrary,
        autoFetchData: true
    });
    
    isc.ListGrid.create({
        autoDraw: false,
        ID: "mediaListGrid",
        width: "100%",
        height: 224,
    
        dataSource: mediaLibrary
    });
    
    isc.VLayout.create({
        autoDraw: false,
        ID:"mainLayout",
        width:500,
        height:250,
        members:[searchForm, buttons, mediaTileGrid, mediaListGrid]
    });
    
    isc.HStack.create({
        width:"100%",
        membersMargin: 10,
        members:[uploadForm, mainLayout]
    });
    
    viewAsTiles.click();
    
    function showTileGrid() {
        mediaListGrid.hide();
        mediaTileGrid.show();
    }
    
    function showListGrid() {
        if (firstTime) {
            firstTime = false;
            mediaListGrid.setData(mediaTileGrid.getData());
        }
        mediaTileGrid.hide();
        mediaListGrid.show();
    }
    By selecting a file and clicking "Save", you’ll see that the saveData callback is called twice.

    #2
    Hello, maybe is a regression related to this fix? https://forums.smartclient.com/forum...back-not-fired

    Comment


      #3
      Hi, is there any news on this?

      Comment


        #4
        It looks like this is related to the readOnlyWhen declaration, and an internal error is happening in that subsystem.

        Lots of people are out on vacation right now, but we'll get this one checked out.

        Comment


          #5
          OK, this has been fixed - wait for tomorrow's builds.

          It turned out to be rather complicated: a DynamicForm with a FileItem saves via an inner DynamicForm within the FileItem. Your readOnlyWhen rule ended up destroying this inner form when it switched to readOnly appearance. But that inner form was destroyed when it was still in the middle of processing the save.

          The most likely outcome of this was a crash, but by sheer luck, it resulted in a double callback instead.

          Comment


            #6
            Hello, I'm waiting for today's build, but I notice that you're referring to a readOnlyWhen declaration. That was present in the linked test case, which, when using v13.1p_2025-07-23, seems not to fire the callback as it did after the fix in v13.1p_2025-06-05.

            The test case from this thread, instead, doesn't contain a readOnlyWhen declaration. Testing the case from post #1 with build v13.1p_2025-07-23, it now seems to work.

            So I'm a bit puzzled. It looks like the problem in this thread is already fixed.
            May I expect that today's build actually fixes the regression from that other thread: https://forums.smartclient.com/forum...ack-not-fired?

            Comment


              #7
              Sorry for the confusion. Both issues should now be resolved - if either seems to reoccur, please report that in the corresponding thread - thanks!

              Comment


                #8
                SmartClient Version: v13.1p_2025-07-24/AllModules Development Only (built 2025-07-24)

                Hello, I can confirm they're both fixed, thank you very much

                Comment

                Working...
                X