Announcement

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

    FileItem and maxFileSize: saveData callback isn't called even with willHandleError:true

    SmartClient Version: v11.1p_2018-02-20/AllModules Development Only (built 2018-02-20)

    Chrome on OSX

    Hello, please modify the #upload sample like this:

    Code:
    var firstTime = true;
    
    isc.DynamicForm.create({
        autoDraw: false,
        ID: "uploadForm", width: 300,
        dataSource: mediaLibrary,
        fields: [
            { name: "title", required: true },
            { name: "image", type: "imageFile", hint: "Maximum file size is 5 MiB" },
            { title: "Save", type: "button", 
                click: function () {
                    this.form.saveData("if(dsResponse.status>=0) {isc.warn('Maximum file size exceeded')}", {willHandleError:true});
                }
            }
        ]
    });
    
    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,
        alternateRecordStyles: true,
        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();
    }
    Actually I've just modified the click handler in the save button of the uploadForm: I've added willHandleError:true in the requestProperties.

    Then type a title and try to load a file which exceed the 5MB limit.
    You'll see that the callback isn't called, even with willHandleError:true.

    #2
    In modern browsers, file size checks are performed client-side without ever contacting the server, so your requestProperties settings aren't involved. If you want to do something special in this circumstance (built-in error display already applies, so there isn't really a need per se..), you can do the same as for other client-side validation errors: call validate() and see which items have errors.

    Comment


      #3
      ok, thanks for the clarification.

      Comment

      Working...
      X