1. #1
    Sencha User
    Join Date
    Apr 2010
    Posts
    2
    Vote Rating
    0
    currywurry is on a distinguished road

      0  

    Thumbs up display correct value in celleditor of RowEditorGrid

    display correct value in celleditor of RowEditorGrid


    Hi

    In my grid, I display Car models. The model looks like:

    private Integer vehicleId;
    private Map<Integer, Driver> drivers

    The drivers are displayed in the correct order (which is indicated by the key of the map), using a cell renderer, and this works fine (simplified):

    public Object render(BeanModel model, String property, ColumnData config, int rowIndex, int colIndex,
    ListStore<BeanModel> store, Grid<BeanModel> grid) {
    Vehicle vehicle = model.getBean();
    return vehicle.getDriverMap().get(colIndex).getName();
    }

    The problem however is, when doube-clicking the row to enable inline editing, the attached editor (a text field) is empty, because GXT can't resolve the correct driver from the the drivermap. Is there a way to do this anyway, or can't beanmodels contain collections? This is a problem, as the number of drivers varies.

    thanks for your help
    Kurt

  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


    Try this.

    Code:
    TextField<String> text = new TextField<String>();
    text.setAllowBlank(false);
    column.setEditor(new CellEditor(text) {
       @Override
       public Object preProcessValue(Object value) { 
          BeanModel model = store.getAt(row);
          Vehicle vehicle = model.getBean();
          return vehicle.getDriverMap().get(col).getName();
       }
    
       @Override
       public Object postProcessValue(Object value) {
          BeanModel model = store.getAt(row);
          Vehicle vehicle = model.getBean();
          vehicle.getDriverMap().get(col).setName((String)value);
          store.update(model);
          this.cancelEdit();
          return null;
       }
    });

Similar Threads

  1. [OPEN] [FIXED-429][2.x/3.x] IE8 Active tab display not quite correct
    By sdrew in forum Ext 3.x: Bugs
    Replies: 12
    Last Post: 21 Mar 2011, 3:47 AM
  2. Tabpanel not display the correct fields
    By riquier.mairesse@free.fr in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 23 Aug 2010, 4:54 AM
  3. [RowEditorGrid] How to add Delete button ?
    By Yacho in forum Ext GWT: Discussion
    Replies: 0
    Last Post: 3 Dec 2009, 6:12 AM
  4. [RowEditorGrid] How to add Delete button ?
    By Yacho in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 3 Dec 2009, 5:28 AM
  5. Setting and display correct item in combobox
    By dinosauro in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 6 Oct 2008, 12:37 AM

Thread Participants: 1