Announcement

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

    ListGrid.getField()

    I was trying to use ListGrid.getField() to get the grid field object for the grouped field. I noticed that if the currently grouped field is not a visible column, I couldn't use ListGrid.getField() to get the field object. It looks like ListGrid.getField() uses the ListGrid.fields property which is just the visible columns. Should it be using the ListGrid.completeFields property instead which is all columns?

    I've worked around my current issue but thought I'd ask you about it.

    #2
    Thanks for letting us know. Yes this is as expected and we won't be changing this method to return fields from the completeFields array. For now you can always use the "getAllFields()" method to get the complete array of fields and pick up a field object from that.

    Regards
    Isomorphic Software

    Comment


      #3
      Understood, I do think you should consider adding a getVisibleField() API that is synonymous with getField() and perhaps creating a ListGrid.visibleFields array that is synonymous with ListGrid.fields because I could see this confusing other people as well.

      Comment


        #4
        A bug I found appears to be related to this topic. When switching between view states on a grid that hide and show different fields, I see the following error

        Code:
        11:11:22.211:TMR1:WARN:Log:TypeError: Cannot read property 'showHover' of null
        Stack from error.stack:
            ListGrid.cellHoverHTML()
            [a]MathFunction.invokeSuper()
            [a]MathFunction.Super()
            isc.defineClass.addProperties.cellHoverHTML() @ js/at_js_static.js?build=local_dev:6215:147
            [a]MathFunction.invokeSuper()
            [a]MathFunction.Super()
            isc.ATListGrid.create.cellHoverHTML() @ dpt.form:2295:29
            eval()
            GridRenderer._showHover()
            GridRenderer._cellHover()

        Looking at the code, I see that the code should either use getAllFields as you suggest or have a null check on field before calling showHover on field

        Code:
        cellHoverHTML : function (record, rowNum, colNum) {
            // If we're showing an editor in the cell suppress the standard cell hover.
            // Exception - if the cell itself is not editable, but the rest of the row is, continue to
            // show hovers over the
            if (this._editorShowing && this.getEditRow() == rowNum && this.canEditCell(rowNum,colNum) &&
                (!this.editByCell || this.getEditCol() == colNum))
            {
                    return null;
            }
        
            var field = this.getField(colNum);
            if (field.showHover == false) return null;
            if (field.showHover == null && !this.canHover) return null;
        
            var value = this.getCellValue(record, rowNum, colNum);
        
            if (field.hoverHTML) {
                isc.Func.replaceWithMethod(field, "hoverHTML",
                                                 "record,value,rowNum,colNum,grid");
                return field.hoverHTML(record,value,rowNum,colNum,this);
            }
        
            if (value != null && !isc.isAn.emptyString(value) && value != this.emptyCellValue) {
                return value;
            }
        },

        Comment


          #5
          Thanks for the notification.
          It's a little odd - the stack trace indicates that this method was being called by the user hovering over a field, which would imply it should be visible.
          We will add a null check as you suggest - this seems like a sensible safeguard - however we'd be interested in seeing how you actually tripped this problem. Any chance you could walk us through steps on one of our samples or show us a little test case to demonstrate the problem in action?

          Thanks
          Isomorphic Software

          Comment


            #6
            This is one of those hard to recreate bugs. But, it was happening when right-clicking on a grid and using a context menu to change to a different view state. The new view state changed all of the fields displaying in the grid. So, presumably, this bug was happening because, after the menu was dismissed, I was hovered over a field and that field was hidden by changing the view state and replaced with a field that was previously hidden. Then, the bug is either because of the new field that was previously not returned by getFields() or by the old field that is now not returned by getFields().

            That sort of scenario is not quite as simple to recreate in your samples but hopefully that gives you a better idea.

            Comment

            Working...
            X