1. #1
    Ext User
    Join Date
    May 2009
    Posts
    9
    Vote Rating
    0
    deep26 is on a distinguished road

      0  

    Question Update grid cell with ComboBox edited value

    Update grid cell with ComboBox edited value


    I have added a ComboBox as an Editor to one of my Grid column. The combo box is editable. I am populating the combo using a store. Now my requirement is that if the user makes any changes to any of the items in the Combo then that changed value should get written to that cell where the Combo box appeared.

    For E.g:
    I am row 1, col 3. I click the cell my combo shows up with values :
    - Hello 1
    - Hello 2

    Now i change Hello 2 to "Hello World". Now I want "Hello World" to be written back to row1, col3.

    I am not able to get this feature working.
    I looked into the demo examples but I dont see such a feature.
    If I dont make a change in the Combo and just select the existing values it gets written to the corresponding cell.

    Is it possible to achieve this ? If yes please suggest me how can I do this.

  2. #2
    Ext User fother's Avatar
    Join Date
    Sep 2007
    Location
    Brazil
    Posts
    744
    Vote Rating
    -1
    fother is an unknown quantity at this point

      0  

    Default


    in http://www.extjs.com/examples-dev/ex...l#editablegrid look for this piece of code..

    Code:
        final SimpleComboBox<String> combo = new SimpleComboBox<String>();  
        combo.setForceSelection(true);  
        combo.setTriggerAction(TriggerAction.ALL);  
        combo.add("Shade");  
        combo.add("Mostly Shady");  
        combo.add("Sun or Shade");  
        combo.add("Mostly Sunny");  
        combo.add("Sunny");  
      
        CellEditor editor = new CellEditor(combo) {  
          @Override  
          public Object preProcessValue(Object value) {  
            if (value == null) {  
              return value;  
            }  
            return combo.findModel(value.toString());  
          }  
      
          @Override  
          public Object postProcessValue(Object value) {  
            if (value == null) {  
              return value;  
            }  
            return ((ModelData) value).get("value");  
          }  
        };
    you can get the instance of store of the grid (set store attribute of the class).. set the new value

Thread Participants: 1