Results 1 to 2 of 2

Thread: highlighting column in GXT grid

  1. #1

    Default highlighting column in GXT grid

    Hi,

    I am using GXT 3.1 in my application. I have created a grid where some of the columns are editable. I want to highlight the editable columns by giving some background color to those columns. I have tried grid.getView().setViewConfig(...) method but this is only coloring the row. I have tried columnconfig.setCell(...) method too, but its only coloring the text background and not the whole cell, that too if value is present in that cell. If no value is present in that cell then its just leaving it as blank. Can any one suggest something to solve this issue.

    Any kind of help will be really helpful for me. Thanks in advance.
    Partha Dutta

  2. #2
    Sencha Premium Member
    Join Date
    Jul 2014
    Posts
    20
    Answers
    2

    Default

    Hi,

    you need to create you own GridView and create a method like this.

    Code:
    public void onHighlightCol(int col, boolean highlight){    
        
          for(int i = 0; i < getRows().getLength(); i++){
            if(highlight){
              getCell( i, col ).<XElement> cast().getStyle().setBackgroundColor( "yellow" );
            }
            else {
              getCell( i, col ).<XElement> cast().getStyle().clearBackgroundColor();
            }
          }
        
      }
    Furthermore you need a new SelectionModel which contains your highlighting cols.
    Code:
    public void highlightCols(List<Integer> colList){
        // unmark old cols
        for(Integer col : selection.getMarkedColList()){
          ((MyGridView<M>) grid.getView()).onHighlightCol( col, false );
        }
        // update selection
        selection.setMarkedColList( colList );
        // mark new cols
        for(Integer col : selection.getMarkedColList()){
          ((MyGridView<M>) grid.getView()).onHighlightCol( col, true );
        }
      }
    In your GUI you just call the highlightCols Method of the SelectionModel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •