Announcement

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

    form.focusInItem not working on mobile after grid.filterData on iOS

    SmartClient Version: v10.1p_2016-02-24/Enterprise Development Only (built 2016-02-24)

    Safari on iOS

    Hello, it seems that the DynamicForm method focusInItem fails to put focus in the form item if called after a ListGrid.filterData.

    I've modified the #adaptiveFilterFS sample:

    Code:
    isc.DynamicForm.create({
      ID:"searchForm",
      items:[
        {
          name:"search", 
          changed:function(form, item, value) {
            supplyList.filterData({description:value}, "searchForm.focusInItem('search')")
          }
        }
      ]
    })
    isc.ListGrid.create({
        ID: "supplyList",
        width:500, height:300, alternateRecordStyles:true, top:30,
        dataSource: supplyItem,
        fields:[
            {name:"SKU"},
            {name:"itemName"},
            {name:"description"},
            {name:"category"}
        ],
        autoFetchData: true,
        showFilterEditor: false,
        filterOnKeypress: true,
        fetchDelay: 500
    });
    
    // ---------------------------------------------------------------------------------------
    // The code that follows is just to illustrate when SmartClient has needed to contact the
    // server. It is not part of the example.
    var origBGColor,
        restoreBGColorTimerID;
    supplyItem.addProperties({
    
        transformResponse: function (dsResponse) {
            if (this.dataFormat == "iscServer") this.updateRowCountLabel(dsResponse);
        },
        // This approach logs simulated server trips for SmartClient LGPL, where all DataSources
        // in the Feature Explorer are converted to clientOnly:true so that no server is required.
        getClientOnlyResponse : function (dsRequest) {
            var dsResponse = this.Super("getClientOnlyResponse", arguments);
            this.updateRowCountLabel(dsResponse);
            return dsResponse;
        },
        updateRowCountLabel : function (dsResponse) {
            serverCount.incrementAndUpdate(dsResponse.totalRows, 
                                           dsResponse.startRow, 
                                           dsResponse.endRow);
            // Flash the label
            if (restoreBGColorTimerID == null) origBGColor = serverCount.backgroundColor;
            else isc.Timer.clear(restoreBGColorTimerID);
            serverCount.setBackgroundColor("#ffff77");
            restoreBGColorTimerID = isc.Timer.setTimeout(function () {
                restoreBGColorTimerID = null;
                serverCount.setBackgroundColor(origBGColor);
            }, 500);
        }
    })
    var serverCount = isc.Label.create({
        top: 320, padding: 10,
        width: 500, height: 40,
        border: "1px solid grey",
        contents: "<b>Number of server trips: 0</b>",
        count: 0,
        incrementAndUpdate: function (totalRows, startRow, endRow) {
            this.count++;
            this.setContents("<b>Number of server trips: " + this.count + 
                             "<br/>Total rows in this filter set: " + totalRows +
                             "<br/>Last range of records returned: " + 
                             startRow + " to " + endRow + "</b>");
        }
    });
    it works when using Chrome or Safari on OSX, but on iOS, after typing the first character in the formItem, the form doesn't get the focus.

    #2
    What you probably want to do in this case is set showPrompt:false via the requestProperties argument of filterData. As it stands, you filterData() call leads to blocking interactivity during the server delay, which moves the focus out of the search input field. You probably don't want this, and your code seems to have revealed a platform difference here which won't affect you if you disable the prompt/blocking behavior.

    Comment


      #3
      thanks, actually the showPrompt:false fixes the problem.

      Comment

      Working...
      X