Success! Looks like we've fixed this one. According to our records the fix was applied for EXTGWT-2772 in 3.1 beta.
  1. #1
    Sencha User
    Join Date
    Oct 2010
    Posts
    128
    Vote Rating
    2
    audra is on a distinguished road

      1  

    Default No header appearance GridView constructor

    No header appearance GridView constructor


    GXT 3.0.2b

    The only way I have been able to assign a header appearance to a GridView is by overriding the initColumnHeader() in GridView. Please introduce a constructor, copy and pasting this much code for every different GridView header I have is painful, redundant, and hard to maintain.

    @Override
    protected void initColumnHeader() {
    header = new ColumnHeader<M>(grid, cm, new myColumnHeaderAppearance()) {


    @Override
    protected Menu getContextMenu(int column) {
    return createContextMenu(column);
    }


    @Override
    protected void onColumnSplitterMoved(int colIndex, int width) {
    super.onColumnSplitterMoved(colIndex, width);
    TaskManagerGridView.this.onColumnSplitterMoved(colIndex, width);
    }


    @Override
    protected void onHeaderClick(Event ce, int column) {
    super.onHeaderClick(ce, column);
    TaskManagerGridView.this.onHeaderClick(column);
    }


    @Override
    protected void onKeyDown(Event ce, int index) {
    ce.stopPropagation();
    // auto select on key down
    if (grid.getSelectionModel() instanceof CellSelectionModel<?>) {
    CellSelectionModel<?> csm = (CellSelectionModel<?>) grid.getSelectionModel();
    csm.selectCell(0, index);
    } else {
    grid.getSelectionModel().select(0, false);
    }
    }


    };

    header.setSplitterWidth(splitterWidth);
    header.setMinColumnWidth(grid.getMinColumnWidth());
    }

    Thanks,
    Audra

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,732
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    This came to be a giant set of changes, but as part of a greater Grid appearance refactor it is complete - these changes are in SVN and will be in the nightly builds, and will be part of the 3.1 release.

  3. #3
    Sencha Premium Member
    Join Date
    Apr 2012
    Posts
    20
    Vote Rating
    1
    sharon_y is on a distinguished road

      0  

    Default


    I'm replying to this old thread, as I don't see any new GridView constructor with header appearance in GXT 3.1.1. I suppose to see a new constructor like this in GridView:
    GridView(GridAppearance appearance, ColumnHeaderAppearance headerAppearance ) ?

    But this constructor doesn't exsit.

    Or can you let me know what's the method I can apply my own header appearance?

    We previously were able to override method initColumnHeader() to pass our own header appearance, but since 'header' is made private, it seems there is no way to apply our own header appearance.

    Here is what I did:
    In our own GridView class (say it's called CustomGridView), override initHeader:
    @Override
    protected void initHeader() {
    ColumnHeader<M> header;

    header = new ColumnHeader<M>(grid, cm, new CustomColumnHeaderAppearance()) {


    @Override
    protected Menu getContextMenu(int column) {
    return createContextMenu(column);
    }


    /*@Override
    protected void onColumnSplitterMoved(int colIndex, int width) {
    super.onColumnSplitterMoved(colIndex, width);
    CustomGridView.this.onColumnSplitterMoved(colIndex, width);
    }*/
    // the above method has to be removed since GridView.initHeader doesn't have this method anymore.


    @Override
    protected void onHeaderClick(Event ce, int column) {
    super.onHeaderClick(ce, column);
    CustomGridView.this.onHeaderClick(column);
    }


    /*@Override
    protected void onKeyDown(Event ce, int index) {
    ce.stopPropagation();
    // auto select on key down
    if (grid.getSelectionModel() instanceof CellSelectionModel<?>) {
    CellSelectionModel<?> csm = (CellSelectionModel<?>) grid.getSelectionModel();
    csm.selectCell(0, index);
    } else {
    grid.getSelectionModel().select(0, false);
    }
    }*/
    // the above method has to be removed since GridView.initHeader doesn't have this method anymore.


    };

    header.setSplitterWidth(splitterWidth);
    // other text styling

    //setColumnHeader(header);
    // will get exception: Can't set a new ColumnHeader after the grid has been rendered
    super.initHeader();
    }

    The result from above code is: no CustomColumnHeaderAppearance is applied to CustomGridView. I also tried to override setColumnHeader method, but that method is never been called. It seems GridView.setColumnHeader is never been called during GridView initialization? And it will throw an exception if I call this method after the GridView is already created because grid!=null by then.

    Thanks.

    Sharon

Thread Participants: 2