1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    5
    Vote Rating
    0
    bungrudi is on a distinguished road

      0  

    Question The correct way to add/remove column in a created grid?

    The correct way to add/remove column in a created grid?


    Hello,

    Is there an example for adding/removing column on a created and rendered grid?

    I guessed to use grid.reconfigure(store,columnModel) and I believe I am right to an extent.
    My problem is that after reconfiguring with new column model, (I'm guessing that) the new column won't receive UI events so that the editor won't show up on cell click.

    Am I missing something here?

    Thanks,
    Rudi

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Nov 2010
    Posts
    209
    Vote Rating
    -2
    Ersmarker has a little shameless behaviour in the past

      0  

    Default


    Your approach using reconfigure is correct. Below is a small example. If you still have problem. Please post a testcase.

    Code:
    ModelData m = new BaseModel();
    m.set("name", "A");
    m.set("name2", "B");
    final ListStore store = new ListStore<ModelData>();
    store.add(m);
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
    ColumnConfig column = new ColumnConfig();
    column = new ColumnConfig(); 
    column.setId("name"); 
    column.setHeader("Col 1"); 
    column.setEditor(new CellEditor(new TextField())); 
    column.setWidth(150); 
    configs.add(column); 
    ColumnModel cm = new ColumnModel(configs);
    final EditorGrid<ModelData> grid = new EditorGrid<ModelData>(store, cm);
    grid.setSize(320, 100);
    RootPanel.get().add(grid);
    
    Button b = new Button("Add Column",new SelectionListener<ButtonEvent>() {
      @Override
        public void componentSelected(ButtonEvent ce) {
        ColumnConfig column = new ColumnConfig();
        column.setId("name2"); 
         column.setHeader("Col 2"); 
        column.setEditor(new CellEditor(new TextField())); 
        column.setWidth(150); 
        List<ColumnConfig> configs = grid.getColumnModel().getColumns();
        configs.add(column);
        ColumnModel newCm = new ColumnModel(configs);
        grid.reconfigure(store, newCm);
      }
    });
    RootPanel.get().add(b);

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar