Announcement

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

    ListGrid SummaryRow out-of-sync after running setFieldState() on grid

    SmartClient v9.0p_2013-09-22/Pro Deployment (built 2013-09-22)

    Firefox 24.0, IE 10

    We have some grids based on ListGrid where we try to save the user's preferences for the grid's field widths and such by using getFieldState() and setFieldState(). Basically, we store the user preferences in a database whenever they resize columns and such, then whenever they come in again, we retrieve them and use setFieldState() to put the grid back the way they had it.

    The problem is that one of our grids uses a grid summary row. The grid summary row gets its width set when the listGrid is first drawn. Then when we run setFieldState() on the grid, the fields in the grid may cause the total width of the grid to go wider than the window. The summary row stays the same width, and does not resize itself to match the full width of the grid. As far as I can tell, the summary row's column locations do match those of the updated listGrid; it's just that the full width of the summary row is limited to the original size of the grid.

    I have tried marking the summary row for redraw using the grid's summaryRow.markForRedraw() method, but this doesn't seem to do the trick.

    Any suggestions for how I can keep the summary row synchronized with the grid?

    #2
    Workaround

    It's a bit of a kludge, but running this function after setFieldState() seems to clear up the problem:

    Code:
        fixGrid: function() {
            if (this.showGridSummary) {
                var gridNomWidth = this.getWidth();
                var fieldsWidth = 0;
                for (var i=0; i<this.fields.getLength(); i++) {
                    fieldsWidth+=this.getFieldWidth(i);
                }
                if (fieldsWidth > gridNomWidth) { this.resizeBy(fieldsWidth - gridNomWidth,0); }
            }
        }

    Comment

    Working...
    X