Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext GWT Premium Member jorel2's Avatar
    Join Date
    Apr 2010
    Location
    Durham, NC
    Posts
    159
    Vote Rating
    0
    jorel2 is on a distinguished road

      0  

    Default inline edit grid: No event for checkbox click

    inline edit grid: No event for checkbox click


    hi. I have a fairly simple grid setup (see image below) where there are 2 date columns and a boolean column. In this setup, I have inline editing and am handling 'CompleteEdit' events from the GridInlineEditing object. This all works well, however, there are 3 things I would like to see here that I am unable to accomplish. Items 1 and 2 seem to be bugs. Item 3 may be an enhancement request.

    1. In order to enhance the date format rendering, I attempt to add a DateCell to the existing column config for the date column. However, doing this results in a loss of the 'CompleteEdit' events and the modified field marks (red triangles). It appears that the 'setCell' method of the ColumnConfig is misconfiguring something in the inline editing logic. My goal is simply to make the date format be one of my choosing.
    2. Same as 1 for boolean field: attempt to make a checkbox format (versus text) disables the 'CompleteEdit' events.
    3. Disable the date fields if the boolean is false. Enable them if true.
    Screen Shot 2014-04-05 at 9.05.38 PM.png

    My code for this is as follows:

    Code:
    // initialize columns:
    private void initializeColumnModel() {
        
        // Create the configurations for each column in the grid
        List<ColumnConfig<Reminder, ?>> ccs = new LinkedList<ColumnConfig<Reminder, ?>>();
        typeColumnConfig         = new ColumnConfig<Reminder,String>(    properties.name(),             120,     ColumnDescriptor.TYPE.getName()            );
        completedColumnConfig     = getDateCellColumn(                    properties.completed_(),    200,    ColumnDescriptor.COMPLETED.getName()    ); 
        dueColumnConfig         = getDateCellColumn(                    properties.due_(),             200,    ColumnDescriptor.DUE.getName()            ); 
        applicableColumnConfig     = new ColumnConfig<Reminder,Boolean>(    properties.applicable(),    140,    ColumnDescriptor.APPLICABLE.getName()    );
    
    
        // Add column configurations to ColumnModel in specified order.
        ccs.add(ColumnDescriptor.TYPE.ordinal(),         typeColumnConfig);
        ccs.add(ColumnDescriptor.COMPLETED.ordinal(),     completedColumnConfig);
        ccs.add(ColumnDescriptor.DUE.ordinal(),         dueColumnConfig);
        ccs.add(ColumnDescriptor.APPLICABLE.ordinal(),     applicableColumnConfig);
        
        applicableColumnConfig.setAlignment(HasHorizontalAlignment.ALIGN_CENTER);
        typeColumnConfig.setAlignment(HasHorizontalAlignment.ALIGN_CENTER);
        reminderColumnModel = new ColumnModel<Reminder>(ccs);
    }
    
    
    
    private ColumnConfig<Reminder,Date> getDateCellColumn( 
            ValueProvider<Reminder,Date>     colDateProvider, 
            int                             width, 
            String                             name
            ) {
        SafeStyles fieldPaddingStyle = SafeStylesUtils.fromTrustedString("padding: 2px 3px;");
        ColumnConfig<Reminder, Date> dateColumn = new ColumnConfig<Reminder, Date>(colDateProvider, width, name);
        dateColumn.setColumnTextStyle(fieldPaddingStyle);
        return dateColumn;
    }
    
    
    private DateField getDateField(){
        DateField dateField             = new DateField(new DateTimePropertyEditor(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT)));
        dateField.setClearValueOnParseError(false);
        return dateField;
    }
    
    
    @Override
    public Widget asWidget() {
        if(!gridInitialized){
            
            editing = new GridInlineEditing<Reminder>(grid);
    
    
            DateField dueDateField             = getDateField();
            DateField completedDateField     = getDateField();
            CheckBox applicBox                =  new CheckBox();
            
            editing.addEditor(dueColumnConfig,             dueDateField);
            editing.addEditor(completedColumnConfig,     completedDateField);
            editing.addEditor(applicableColumnConfig,     applicBox);
    
    
    // THIS DOESN'T WORK, IT KILLS THE CompleteEdit EVENT:
    //        DateCell dateCell = new DateCell();
    //        dateCell.setPropertyEditor(new DateTimePropertyEditor(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT)));
    //        completedColumnConfig.setCell(dateCell);
            
            editing.addCompleteEditHandler(new CompleteEditHandler<Reminder>(){
                @Override
                public void onCompleteEdit(CompleteEditEvent<Reminder> event) {
                    GridCell cell = event.getEditCell();
                    
                    int row = cell.getRow();
                    int col = cell.getCol();
                    Reminder rem = reminderStore.get(row);
                    Store<Reminder>.Record rec = reminderStore.getRecord(rem);
                    Change<Reminder, Boolean> applicChange     = rec.getChange(properties.applicable());
                    Change<Reminder, Date>        dueChange    = rec.getChange(properties.due_());
                    Change<Reminder, Date>        comChange    = rec.getChange(properties.completed_());
                    
                    System.err.println("Row "+(row+1)+" changed: ");
                    if(col==ColumnDescriptor.APPLICABLE.ordinal()){
                        boolean applicValue = false;
                        if(applicChange!=null){ 
                            applicValue = applicChange.getValue();
                            System.out.println(" applicable changed to "+applicValue);
                        }
                        else{
                            applicValue = rem.getApplicable();
                            System.out.println(" applicable reverted to "+rem.getApplicable());
                        }
                        enableDateFieldsForRow(applicValue, row);
                    }
                    if(col==ColumnDescriptor.DUE.ordinal()){
                        if(dueChange!=null ){
                            Date dueValue = dueChange.getValue();
                            System.out.println(" due changed to: "+SimpleDate.convertFromDate(dueValue));
                        }
                        else
                            System.out.println(" due reverted to "+rem.getDue());
                    }
                    if(col==ColumnDescriptor.COMPLETED.ordinal()){
                        if(comChange!=null ){
                            Date comValue = comChange.getValue();
                            System.out.println(" com changed to: "+SimpleDate.convertFromDate(comValue));
                            try{
                                fixDueDate(row,comValue, rem, rec);
                            }
                            catch(Exception e){
                                //boo.
                                System.err.println("Could not update the due date for this completion date change.");
                            }
                        }
                        else
                            System.out.println(" due reverted to "+rem.getCompleted());
                        
                    }
                }
            });
            gridInitialized=true;
        }
        // Initialize the Revert Changes button.
        revert.addSelectHandler(new SelectHandler(){
            @Override
            public void onSelect(SelectEvent event) {
                reminderStore.rejectChanges();
            }
        });
        
        // ok, now, return the widget!
        return widget;
    }
    
    
    // Enable/disable date fields based on whether they are applicable (applicValue).
    private void enableDateFieldsForRow(boolean applicValue, int row){
        
    }
    private void fixDueDate(int row, Date completedDate, Reminder rem, Store<Reminder>.Record rec ) 
            throws InvalidDateFormatException, InvalidDateException{
        SimpleDate newCompDate = new SimpleDate(completedDate);
        SimpleDate dueDate = newCompDate.addYears(rem.getRenewalYears());
    
    
        rec.addChange(dueColumnConfig.getValueProvider(), dueDate.toDate());
    }
    
    
    public List<Reminder> getModifications(){
        System.out.println("grid modifications:");
        List<Reminder> modified = new ArrayList<Reminder>();
        for(Store<Reminder>.Record record : reminderStore.getModifiedRecords()){
            Reminder model = record.getModel();
            Reminder clone = model.clone();
            for(Change<Reminder,?> change : record.getChanges()){
                change.modify(clone);
            }
            modified.add(clone);
        }
        return modified;
    }
    
    
    public List<Reminder> commitChanges(){
        reminderStore.commitChanges();
        return reminderStore.getAll();
    }
    
    
    public void updateList(List<Reminder> list){
        reminderStore.clear();
        
        for(Reminder r : list){
            reminderStore.add(r);
        }
        
        // disable selection of rows.
        grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
        //grid.disableEvents();
    }
    Attached Images
    Last edited by jorel2; 18 Apr 2014 at 6:04 AM. Reason: fix the title.

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Jan 2012
    Location
    Arlington, WA
    Posts
    377
    Vote Rating
    15
    branflake2267 will become famous soon enough

      1  

    Default


    Hi Joel,

    Could I ask if you could enhance the test case below to replicate your issues in that?

    I've added date format and checkbox formatting for the basic view to start with. Look for startEditing for the logic that will disable another field.

    This test case can make a small micro environment to help me run the issue locally.

    Code:
    import java.text.ParseException;import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;
    
    
    import com.google.gwt.cell.client.DateCell;
    import com.google.gwt.core.client.GWT;
    import com.google.gwt.editor.client.Editor.Path;
    import com.google.gwt.i18n.client.DateTimeFormat;
    import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
    import com.google.gwt.i18n.client.NumberFormat;
    import com.google.gwt.safehtml.shared.SafeHtml;
    import com.google.gwt.safehtml.shared.SafeHtmlUtils;
    import com.google.gwt.text.shared.AbstractSafeHtmlRenderer;
    import com.google.gwt.user.client.ui.HasHorizontalAlignment;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.google.gwt.user.client.ui.Widget;
    import com.sencha.gxt.cell.core.client.SimpleSafeHtmlCell;
    import com.sencha.gxt.cell.core.client.form.CheckBoxCell;
    import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
    import com.sencha.gxt.core.client.ValueProvider;
    import com.sencha.gxt.core.client.util.DateWrapper;
    import com.sencha.gxt.data.shared.Converter;
    import com.sencha.gxt.data.shared.ListStore;
    import com.sencha.gxt.data.shared.ModelKeyProvider;
    import com.sencha.gxt.data.shared.PropertyAccess;
    import com.sencha.gxt.data.shared.StringLabelProvider;
    import com.sencha.gxt.widget.core.client.FramedPanel;
    import com.sencha.gxt.widget.core.client.button.TextButton;
    import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
    import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
    import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
    import com.sencha.gxt.widget.core.client.container.Viewport;
    import com.sencha.gxt.widget.core.client.event.SelectEvent;
    import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
    import com.sencha.gxt.widget.core.client.form.CheckBox;
    import com.sencha.gxt.widget.core.client.form.DateField;
    import com.sencha.gxt.widget.core.client.form.DateTimePropertyEditor;
    import com.sencha.gxt.widget.core.client.form.PropertyEditor;
    import com.sencha.gxt.widget.core.client.form.SimpleComboBox;
    import com.sencha.gxt.widget.core.client.form.TextField;
    import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
    import com.sencha.gxt.widget.core.client.grid.ColumnModel;
    import com.sencha.gxt.widget.core.client.grid.Grid;
    import com.sencha.gxt.widget.core.client.grid.Grid.GridCell;
    import com.sencha.gxt.widget.core.client.grid.GridView;
    import com.sencha.gxt.widget.core.client.grid.editing.GridEditing;
    import com.sencha.gxt.widget.core.client.grid.editing.GridInlineEditing;
    import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
    
    
    public class GridInlineEditingTest {
    
    
      public GridInlineEditingTest() {
        VerticalLayoutContainer vlc = new VerticalLayoutContainer();
        vlc.add(createGrid(), new VerticalLayoutData(1, 1));
    
    
        Viewport vp = new Viewport();
        vp.add(vlc);
        RootPanel.get().add(vp);
      }
    
    
      // just to show the converter feature
      public enum Light {
        MOSTLYSHADY("Mostly Shady"), MOSTLYSUNNY("Mostly Sunny"), SHADE("Shade"), SUNNY("Sunny"), SUNORSHADE("Sun or Shade");
        static Light parseString(String object) throws ParseException {
          if (Light.MOSTLYSUNNY.toString().equals(object)) {
            return Light.MOSTLYSUNNY;
          } else if (Light.SUNORSHADE.toString().equals(object)) {
            return Light.SUNORSHADE;
          } else if (Light.MOSTLYSHADY.toString().equals(object)) {
            return Light.MOSTLYSHADY;
          } else if (Light.SHADE.toString().equals(object)) {
            return Light.SHADE;
          } else if (Light.SUNNY.toString().equals(object)) {
            return Light.SUNNY;
          } else {
            throw new ParseException(object.toString() + " could not be parsed", 0);
          }
        }
    
    
        private String text;
    
    
        Light(String text) {
          this.text = text;
        }
    
    
        @Override
        public String toString() {
          return text;
        }
      }
    
    
      interface PlaceProperties extends PropertyAccess<Plant> {
        ValueProvider<Plant, Date> available();
    
    
        @Path("id")
        ModelKeyProvider<Plant> key();
    
    
        ValueProvider<Plant, String> light();
    
    
        ValueProvider<Plant, String> name();
    
    
        ValueProvider<Plant, Boolean> indoor();
    
    
        ValueProvider<Plant, Double> price();
      }
    
    
      private static final PlaceProperties properties = GWT.create(PlaceProperties.class);
    
    
      protected Grid<Plant> grid;
      private FramedPanel panel;
      private ListStore<Plant> store;
    
    
      private DateField dateField;
    
    
      public Widget createGrid() {
        if (panel == null) {
          ColumnConfig<Plant, String> nameCol = new ColumnConfig<Plant, String>(properties.name(), 220, "Name");
          ColumnConfig<Plant, String> lightCol = new ColumnConfig<Plant, String>(properties.light(), 130, "Light");
          ColumnConfig<Plant, Date> dateCol = new ColumnConfig<Plant, Date>(properties.available(), 95, "Date");
          ColumnConfig<Plant, Boolean> indorCol = new ColumnConfig<Plant, Boolean>(properties.indoor(), 55, "Indoor");
          ColumnConfig<Plant, Double> priceCol = new ColumnConfig<Plant, Double>(properties.price(), 100, "Price");
    
    
          // display formatting
          DateCell dateCell = new DateCell(DateTimeFormat.getFormat("yyyy MMM dd"));
          dateCol.setCell(dateCell);
    
    
          // display a checkbox in the gridview
          indorCol.setCell(new CheckBoxCell());
    
    
          priceCol.setAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
          priceCol.setCell(new SimpleSafeHtmlCell<Double>(new AbstractSafeHtmlRenderer<Double>() {
            @Override
            public SafeHtml render(Double object) {
              return SafeHtmlUtils.fromString(NumberFormat.getCurrencyFormat().format(object));
            }
          }));
    
    
          List<ColumnConfig<Plant, ?>> l = new ArrayList<ColumnConfig<Plant, ?>>();
          l.add(nameCol);
          l.add(lightCol);
          l.add(priceCol);
          l.add(dateCol);
          l.add(indorCol);
    
    
          ColumnModel<Plant> columns = new ColumnModel<Plant>(l);
    
    
          store = new ListStore<Plant>(properties.key());
          store.setAutoCommit(false);
          store.addAll(getPlants());
    
    
          GridView<Plant> gridView = new GridView<Plant>();
          
          grid = new Grid<Plant>(store, columns, gridView);
          grid.getView().setAutoExpandColumn(nameCol);
    
    
          // EDITING//
          final GridEditing<Plant> editing = new GridInlineEditing<Plant>(grid) {
            @Override
            public void startEditing(GridCell cell) {
              super.startEditing(cell);
              
              ColumnConfig<Plant, ?> c = columnModel.getColumn(cell.getCol());
              Plant value = getEditableGrid().getStore().get(cell.getRow());
              
              if (value.getName().equals("Cowslip")) {
                dateField.setEnabled(false);
              }
            }
          };
          editing.addEditor(nameCol, new TextField());
    
    
          SimpleComboBox<Light> combo = new SimpleComboBox<Light>(new StringLabelProvider<Light>());
          combo.setClearValueOnParseError(false);
          combo.setPropertyEditor(new PropertyEditor<Light>() {
            @Override
            public Light parse(CharSequence text) throws ParseException {
              return Light.parseString(text.toString());
            }
    
    
            @Override
            public String render(Light object) {
              return object == null ? Light.SUNNY.toString() : object.toString();
            }
          });
          combo.setTriggerAction(TriggerAction.ALL);
          combo.add(Light.SUNNY);
          combo.add(Light.MOSTLYSUNNY);
          combo.add(Light.SUNORSHADE);
          combo.add(Light.MOSTLYSHADY);
          combo.add(Light.SHADE);
          // combo.setForceSelection(true);
    
    
          editing.addEditor(lightCol, new Converter<String, Light>() {
            @Override
            public String convertFieldValue(Light object) {
              return object == null ? "" : object.toString();
            }
    
    
            @Override
            public Light convertModelValue(String object) {
              try {
                return Light.parseString(object);
              } catch (ParseException e) {
                return null;
              }
            }
          }, combo);
    
    
          dateField = new DateField(new DateTimePropertyEditor(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT)));
          dateField.setClearValueOnParseError(false);
          editing.addEditor(dateCol, dateField);
    
    
          CheckBox checkField = new CheckBox();
          editing.addEditor(indorCol, checkField);
          // column 5 is not editable
    
    
    
    
          panel = new FramedPanel();
          panel.setHeadingText("Editable Grid Example");
          panel.setPixelSize(600, 400);
          panel.addStyleName("margin-10");
    
    
          ToolBar toolBar = new ToolBar();
    
    
          TextButton add = new TextButton("Add Plant");
          add.addSelectHandler(new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
              Plant plant = new Plant();
              plant.setName("New Plant 1");
              plant.setLight("Mostly Shady");
              plant.setPrice(0);
              plant.setAvailable(new DateWrapper().clearTime().asDate());
              plant.setIndoor(false);
    
    
              editing.cancelEditing();
              store.add(0, plant);
    
    
              int row = store.indexOf(plant);
              editing.startEditing(new GridCell(row, 0));
            }
          });
    
    
          toolBar.add(add);
    
    
          VerticalLayoutContainer con = new VerticalLayoutContainer();
          con.setBorders(true);
          con.add(toolBar, new VerticalLayoutData(1, -1));
          con.add(grid, new VerticalLayoutData(1, 1));
    
    
          panel.setWidget(con);
    
    
          panel.setButtonAlign(BoxLayoutPack.CENTER);
          panel.addButton(new TextButton("Reset", new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
              store.rejectChanges();
            }
          }));
    
    
          panel.addButton(new TextButton("Save", new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
              store.commitChanges();
            }
          }));
        }
    
    
        return panel;
      }
    
    
      private static int AUTO_ID = 0;
    
    
      public class Plant {
        private DateTimeFormat df = DateTimeFormat.getFormat("MM/dd/y");
    
    
        private int id;
        private String name;
        private String light;
        private double price;
        private Date available;
        private boolean indoor;
        private String color;
        private int difficulty;
        private double progress;
    
    
        public Plant() {
          id = AUTO_ID++;
    
    
          difficulty = (int) (Math.random() * 100);
          progress = Math.random();
    
    
        }
    
    
        public Plant(String name, String light, double price, String available, boolean indoor) {
          this();
          setName(name);
          setLight(light);
          setPrice(price);
          setAvailable(df.parse(available));
          setIndoor(indoor);
        }
    
    
        public double getProgress() {
          return progress;
        }
    
    
        public void setProgress(double progress) {
          this.progress = progress;
        }
    
    
        public String getColor() {
          return color;
        }
    
    
        public int getDifficulty() {
          return difficulty;
        }
    
    
        public void setDifficulty(int difficulty) {
          this.difficulty = difficulty;
        }
    
    
        public void setColor(String color) {
          this.color = color;
        }
    
    
        public Date getAvailable() {
          return available;
        }
    
    
        public int getId() {
          return id;
        }
    
    
        public String getLight() {
          return light;
        }
    
    
        public String getName() {
          return name;
        }
    
    
        public double getPrice() {
          return price;
        }
    
    
        public boolean isIndoor() {
          return indoor;
        }
    
    
        public void setAvailable(Date available) {
          this.available = available;
        }
    
    
        public void setId(int id) {
          this.id = id;
        }
    
    
        public void setIndoor(boolean indoor) {
          this.indoor = indoor;
        }
    
    
        public void setLight(String light) {
          this.light = light;
        }
    
    
        public void setName(String name) {
          this.name = name;
        }
    
    
        public void setPrice(double price) {
          this.price = price;
        }
    
    
        @Override
        public String toString() {
          return name != null ? name : super.toString();
        }
      }
    
    
      public List<Plant> getPlants() {
        List<Plant> plants = new ArrayList<Plant>();
        plants.add(new Plant("Bloodroot", "Mostly Shady", 2.44, "03/15/2006", true));
        plants.add(new Plant("Columbine", "Shade", 9.37, "03/15/2006", true));
        plants.add(new Plant("Marsh Marigold", "Mostly Sunny", 6.81, "05/17/2006", false));
        plants.add(new Plant("Cowslip", "Mostly Shady", 9.90, "03/06/2006", true));
        plants.add(new Plant("Dutchman's-Breeches", "Mostly Shady", 6.44, "01/20/2006", true));
        plants.add(new Plant("Ginger, Wild", "Mostly Shady", 9.03, "04/18/2006", true));
        return plants;
      }
    }
    Would this help you get closer to your goal?

    Brandon

  3. #3
    Ext GWT Premium Member jorel2's Avatar
    Join Date
    Apr 2010
    Location
    Durham, NC
    Posts
    159
    Vote Rating
    0
    jorel2 is on a distinguished road

      0  

    Default simplified example code to illustrate issue

    simplified example code to illustrate issue


    Hi. I've simplified the sample code to reduce clutter and focus on the issue (possibly 2 issues).

    I will post the code below after describing the issues:
    1. The checkbox click is not making it to the event handler. (see the comment in the code that says "not firing for checkbox:").
    2. If it did, how would you disable the date field for the corresponding row?
    Code:
    package com.joelsoft.gridtest.client;
    
    
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;
    
    
    import com.google.gwt.cell.client.DateCell;
    import com.google.gwt.core.client.GWT;
    import com.google.gwt.editor.client.Editor.Path;
    import com.google.gwt.i18n.client.DateTimeFormat;
    import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.google.gwt.user.client.ui.Widget;
    import com.sencha.gxt.cell.core.client.form.CheckBoxCell;
    import com.sencha.gxt.core.client.ValueProvider;
    import com.sencha.gxt.data.shared.ListStore;
    import com.sencha.gxt.data.shared.ModelKeyProvider;
    import com.sencha.gxt.data.shared.PropertyAccess;
    import com.sencha.gxt.data.shared.Store;
    import com.sencha.gxt.widget.core.client.FramedPanel;
    import com.sencha.gxt.widget.core.client.button.TextButton;
    import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
    import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
    import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
    import com.sencha.gxt.widget.core.client.container.Viewport;
    import com.sencha.gxt.widget.core.client.event.CompleteEditEvent;
    import com.sencha.gxt.widget.core.client.event.CompleteEditEvent.CompleteEditHandler;
    import com.sencha.gxt.widget.core.client.event.SelectEvent;
    import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
    import com.sencha.gxt.widget.core.client.form.CheckBox;
    import com.sencha.gxt.widget.core.client.form.DateField;
    import com.sencha.gxt.widget.core.client.form.DateTimePropertyEditor;
    import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
    import com.sencha.gxt.widget.core.client.grid.ColumnModel;
    import com.sencha.gxt.widget.core.client.grid.Grid;
    import com.sencha.gxt.widget.core.client.grid.Grid.GridCell;
    import com.sencha.gxt.widget.core.client.grid.GridView;
    import com.sencha.gxt.widget.core.client.grid.editing.GridEditing;
    import com.sencha.gxt.widget.core.client.grid.editing.GridInlineEditing;
    
    
    public class GridInlineEditingTest {
          public GridInlineEditingTest() {
                VerticalLayoutContainer vlc = new VerticalLayoutContainer();
                vlc.add(createGrid(), new VerticalLayoutData(1, 1));
    
    
                Viewport vp = new Viewport();
                vp.add(vlc);
                RootPanel.get().add(vp);
              }
    
    
              interface PlaceProperties extends PropertyAccess<Plant> {
                ValueProvider<Plant, Date> available();
    
    
                @Path("id")
                ModelKeyProvider<Plant> key();
                ValueProvider<Plant, String> name();
                ValueProvider<Plant, Boolean> indoor();
              }
    
    
              private static final PlaceProperties properties = GWT.create(PlaceProperties.class);
    
    
              protected Grid<Plant> grid;
              private FramedPanel panel;
              private ListStore<Plant> store;
              private DateField dateField;
    
    
              public Widget createGrid() {
                if (panel == null) {
                  ColumnConfig<Plant, String>     nameCol     = new ColumnConfig<Plant, String>(    properties.name(),         220,     "Name"    );
                  ColumnConfig<Plant, Date>     dateCol     = new ColumnConfig<Plant, Date>(    properties.available(), 95,     "Date"    );
                  ColumnConfig<Plant, Boolean>     indorCol     = new ColumnConfig<Plant, Boolean>(    properties.indoor(),     55,     "Indoor");
    
    
                  // display formatting
                  DateCell dateCell = new DateCell(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT));
                  dateCol.setCell(dateCell);
    
    
                  // display a checkbox in the gridview
                  indorCol.setCell(new CheckBoxCell());
    
    
    
    
                  List<ColumnConfig<Plant, ?>> l = new ArrayList<ColumnConfig<Plant, ?>>();
                  l.add(nameCol);
                  l.add(dateCol);
                  l.add(indorCol);
                  ColumnModel<Plant> columns = new ColumnModel<Plant>(l);
    
    
                  store = new ListStore<Plant>(properties.key());
                  store.setAutoCommit(false);
                  store.addAll(getPlants());
    
    
                  GridView<Plant> gridView = new GridView<Plant>();
                  grid = new Grid<Plant>(store, columns, gridView);
                  grid.getView().setAutoExpandColumn(nameCol);
    
    
                  // EDITING//
                  final GridEditing<Plant> editing = new GridInlineEditing<Plant>(grid); 
                  dateField = new DateField(new DateTimePropertyEditor(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT)));
                  dateField.setClearValueOnParseError(false);
                  editing.addEditor(dateCol, dateField);
                  CheckBox checkField = new CheckBox();
                  editing.addEditor(indorCol, checkField);
    
    
                  editing.addCompleteEditHandler( new CompleteEditHandler<Plant>(){
                      
                      // not firing for checkbox:
                      @Override
                      public void onCompleteEdit(CompleteEditEvent<Plant> event) {
                          GridCell cell = event.getEditCell();
                            
                          int row = cell.getRow();
                          int col = cell.getCol();
                          System.out.println("got here. row "+row+", col "+col);
                            
                      }
                  });
                  
                  panel = new FramedPanel();
                  panel.setHeadingText("Editable Grid Example");
                  panel.setPixelSize(600, 400);
                  panel.addStyleName("margin-10");
    
    
                  VerticalLayoutContainer con = new VerticalLayoutContainer();
                  con.setBorders(true);
                  con.add(grid, new VerticalLayoutData(1, 1));
    
    
                  panel.setWidget(con);
                  panel.setButtonAlign(BoxLayoutPack.CENTER);
                  panel.addButton(new TextButton("Reset", new SelectHandler() {
                    @Override
                    public void onSelect(SelectEvent event) {
                      store.rejectChanges();
                    }
                  }));
    
    
                  panel.addButton(new TextButton("Save", new SelectHandler() {
                    @Override
                    public void onSelect(SelectEvent event) {
                      store.commitChanges();
                    }
                  }));
                }
                return panel;
              }
    
    
              private static int AUTO_ID = 0;
    
    
              public class Plant {
                private DateTimeFormat df = DateTimeFormat.getFormat("MM/dd/y");
                private int id;
                private String name;
                private String light;
                private double price;
                private Date available;
                private boolean indoor;
                private String color;
                private int difficulty;
                private double progress;
    
    
                public Plant() {
                  id = AUTO_ID++;
                  difficulty = (int) (Math.random() * 100);
                  progress = Math.random();
                }
    
    
                public Plant(String name, String light, double price, String available, boolean indoor) {
                  this();
                  setName(name);
                  setLight(light);
                  setPrice(price);
                  setAvailable(df.parse(available));
                  setIndoor(indoor);
                }
    
    
                public int getId() {                              return id;                            }
                public double getProgress() {                      return progress;                }
                public String getColor() {                          return color;                    }
                public int getDifficulty() {                      return difficulty;                }
                public Date getAvailable() {                      return available;                }
                public String getLight() {                          return light;                    }
                public String getName() {                          return name;                    }
                public double getPrice() {                          return price;                    }
                public boolean isIndoor() {                          return indoor;                    }
                
                public void setId(int id) {                          this.id = id;                    }
                public void setProgress(double progress) {        this.progress = progress;        }
                public void setAvailable(Date available) {        this.available = available;        }
                public void setDifficulty(int difficulty) {        this.difficulty = difficulty;    }
                public void setColor(String color) {            this.color = color;                }
                public void setIndoor(boolean indoor) {            this.indoor = indoor;            }
                public void setLight(String light) {            this.light = light;                }
                public void setName(String name) {                  this.name = name;                }
                public void setPrice(double price) {            this.price = price;                }
                
                @Override
                public String toString() {
                  return name != null ? name : super.toString();
                }
              }
    
    
              public List<Plant> getPlants() {
                List<Plant> plants = new ArrayList<Plant>();
                plants.add(new Plant("Bloodroot", "Mostly Shady", 2.44, "03/15/2006", true));
                plants.add(new Plant("Columbine", "Shade", 9.37, "03/15/2006", true));
                plants.add(new Plant("Marsh Marigold", "Mostly Sunny", 6.81, "05/17/2006", false));
                plants.add(new Plant("Cowslip", "Mostly Shady", 9.90, "03/06/2006", true));
                plants.add(new Plant("Dutchman's-Breeches", "Mostly Shady", 6.44, "01/20/2006", true));
                plants.add(new Plant("Ginger, Wild", "Mostly Shady", 9.03, "04/18/2006", true));
                return plants;
              }
    
    
    }

  4. #4
    Ext GWT Premium Member jorel2's Avatar
    Join Date
    Apr 2010
    Location
    Durham, NC
    Posts
    159
    Vote Rating
    0
    jorel2 is on a distinguished road

      0  

    Default


    anyone?

  5. #5
    Ext GWT Premium Member jorel2's Avatar
    Join Date
    Apr 2010
    Location
    Durham, NC
    Posts
    159
    Vote Rating
    0
    jorel2 is on a distinguished road

      0  

    Default


    .

  6. #6
    Sencha - GXT Dev Team
    Join Date
    Jan 2012
    Location
    Arlington, WA
    Posts
    377
    Vote Rating
    15
    branflake2267 will become famous soon enough

      0  

    Default


    Sorry forgot to get back with more. Will be able to look at this shortly.

    Brandon

  7. #7
    Sencha - GXT Dev Team
    Join Date
    Jan 2012
    Location
    Arlington, WA
    Posts
    377
    Vote Rating
    15
    branflake2267 will become famous soon enough

      0  

    Default


    I think there may be a better way to do this, but I through this together. This can disable the next row date depending on checkbox of the first row. Not sure I would do it this way, but I'd call this my first experiment. I didn't account for all paths in this scenario, considering end of row probably...

    Code:
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;
    
    
    import com.google.gwt.cell.client.DateCell;
    import com.google.gwt.core.client.GWT;
    import com.google.gwt.editor.client.Editor.Path;
    import com.google.gwt.i18n.client.DateTimeFormat;
    import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.google.gwt.user.client.ui.Widget;
    import com.sencha.gxt.cell.core.client.form.CheckBoxCell;
    import com.sencha.gxt.core.client.ValueProvider;
    import com.sencha.gxt.data.shared.ListStore;
    import com.sencha.gxt.data.shared.ModelKeyProvider;
    import com.sencha.gxt.data.shared.PropertyAccess;
    import com.sencha.gxt.widget.core.client.FramedPanel;
    import com.sencha.gxt.widget.core.client.button.TextButton;
    import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
    import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
    import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
    import com.sencha.gxt.widget.core.client.container.Viewport;
    import com.sencha.gxt.widget.core.client.event.CompleteEditEvent;
    import com.sencha.gxt.widget.core.client.event.CompleteEditEvent.CompleteEditHandler;
    import com.sencha.gxt.widget.core.client.event.SelectEvent;
    import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
    import com.sencha.gxt.widget.core.client.form.CheckBox;
    import com.sencha.gxt.widget.core.client.form.DateField;
    import com.sencha.gxt.widget.core.client.form.DateTimePropertyEditor;
    import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
    import com.sencha.gxt.widget.core.client.grid.ColumnModel;
    import com.sencha.gxt.widget.core.client.grid.Grid;
    import com.sencha.gxt.widget.core.client.grid.Grid.GridCell;
    import com.sencha.gxt.widget.core.client.grid.GridView;
    import com.sencha.gxt.widget.core.client.grid.editing.GridEditing;
    import com.sencha.gxt.widget.core.client.grid.editing.GridInlineEditing;
    
    
    public class GridInlineEditingTest {
      public GridInlineEditingTest() {
        VerticalLayoutContainer vlc = new VerticalLayoutContainer();
        vlc.add(createGrid(), new VerticalLayoutData(1, 1));
        
        Viewport vp = new Viewport();
        vp.add(vlc);
        RootPanel.get().add(vp);
      }
    
    
      interface PlaceProperties extends PropertyAccess<Plant> {
        ValueProvider<Plant, Date> available();
    
    
        @Path("id")
        ModelKeyProvider<Plant> key();
    
    
        ValueProvider<Plant, String> name();
    
    
        ValueProvider<Plant, Boolean> indoor();
      }
    
    
      private static final PlaceProperties properties = GWT.create(PlaceProperties.class);
    
    
      protected Grid<Plant> grid;
      private FramedPanel panel;
      private ListStore<Plant> store;
      private DateField dateField;
    
    
      private CheckBox checkField;
    
    
      public Widget createGrid() {
        if (panel == null) {
          ColumnConfig<Plant, String> nameCol = new ColumnConfig<Plant, String>(properties.name(), 220, "Name");
          ColumnConfig<Plant, Date> dateCol = new ColumnConfig<Plant, Date>(properties.available(), 95, "Date");
          ColumnConfig<Plant, Boolean> indorCol = new ColumnConfig<Plant, Boolean>(properties.indoor(), 55, "Indoor");
    
    
          // display formatting
          DateCell dateCell = new DateCell(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT));
          dateCol.setCell(dateCell);
    
    
          List<ColumnConfig<Plant, ?>> l = new ArrayList<ColumnConfig<Plant, ?>>();
          l.add(nameCol);
          l.add(dateCol);
          l.add(indorCol);
          ColumnModel<Plant> columns = new ColumnModel<Plant>(l);
    
    
          store = new ListStore<Plant>(properties.key());
          store.setAutoCommit(false);
          store.addAll(getPlants());
    
    
          GridView<Plant> gridView = new GridView<Plant>();
          grid = new Grid<Plant>(store, columns, gridView);
          grid.getView().setAutoExpandColumn(nameCol);
    
    
          // EDITING//
          final GridEditing<Plant> editing = new GridInlineEditing<Plant>(grid) {
            @Override
            public void startEditing(GridCell cell) {
              super.startEditing(cell);
              
              Plant m = store.get(cell.getRow());
              boolean enableDate = m.isEnableDate();
              
              dateField.setEnabled(enableDate);
              
              System.out.println("editing plant=" + m.getName() + " enableDate=" + enableDate);
            }
          };
          dateField = new DateField(new DateTimePropertyEditor(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT)));
          dateField.setClearValueOnParseError(false);
          editing.addEditor(dateCol, dateField);
          
          CheckBoxCell checkBoxCell = new CheckBoxCell();
          checkField = new CheckBox(checkBoxCell);
        
          editing.addEditor(indorCol, checkField);
          
          editing.addCompleteEditHandler(new CompleteEditHandler<Plant>() {
            // not firing for checkbox:
            @Override
            public void onCompleteEdit(CompleteEditEvent<Plant> event) {
              GridCell cell = event.getEditCell();
    
    
              int row = cell.getRow();
              int col = cell.getCol();
              System.out.println("got here. row " + row + ", col " + col);
              
              boolean enableDate = checkField.getValue();
              Plant nextRowModel = store.get(row+1);
              
              nextRowModel.setEnableDate(enableDate);
              
              System.out.println("next row plant=" + nextRowModel.getName() + " enableDate=" + enableDate);
            }
          });
    
    
          panel = new FramedPanel();
          panel.setHeadingText("Editable Grid Example");
          panel.setPixelSize(600, 400);
          panel.addStyleName("margin-10");
    
    
          VerticalLayoutContainer con = new VerticalLayoutContainer();
          con.setBorders(true);
          con.add(grid, new VerticalLayoutData(1, 1));
    
    
          panel.setWidget(con);
          panel.setButtonAlign(BoxLayoutPack.CENTER);
          panel.addButton(new TextButton("Reset", new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
              store.rejectChanges();
            }
          }));
    
    
          panel.addButton(new TextButton("Save", new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
              store.commitChanges();
            }
          }));
        }
        return panel;
      }
    
    
      private static int AUTO_ID = 0;
    
    
      public class Plant {
        private DateTimeFormat df = DateTimeFormat.getFormat("MM/dd/y");
        private int id;
        private String name;
        private String light;
        private double price;
        private Date available;
        private boolean indoor;
        private String color;
        private int difficulty;
        private double progress;
        
        private boolean enableDate = true;
    
    
        public Plant() {
          id = AUTO_ID++;
          difficulty = (int) (Math.random() * 100);
          progress = Math.random();
        }
    
    
        public Plant(String name, String light, double price, String available, boolean indoor) {
          this();
          setName(name);
          setLight(light);
          setPrice(price);
          setAvailable(df.parse(available));
          setIndoor(indoor);
        }
    
    
        public int getId() {
          return id;
        }
    
    
        public double getProgress() {
          return progress;
        }
    
    
        public String getColor() {
          return color;
        }
    
    
        public int getDifficulty() {
          return difficulty;
        }
    
    
        public Date getAvailable() {
          return available;
        }
    
    
        public String getLight() {
          return light;
        }
    
    
        public String getName() {
          return name;
        }
    
    
        public double getPrice() {
          return price;
        }
    
    
        public boolean isIndoor() {
          return indoor;
        }
    
    
        public void setId(int id) {
          this.id = id;
        }
    
    
        public void setProgress(double progress) {
          this.progress = progress;
        }
    
    
        public void setAvailable(Date available) {
          this.available = available;
        }
    
    
        public void setDifficulty(int difficulty) {
          this.difficulty = difficulty;
        }
    
    
        public void setColor(String color) {
          this.color = color;
        }
    
    
        public void setIndoor(boolean indoor) {
          this.indoor = indoor;
        }
        
        public boolean getIndoor() {
          return indoor;
        }
    
    
        public void setLight(String light) {
          this.light = light;
        }
    
    
        public void setName(String name) {
          this.name = name;
        }
    
    
        public void setPrice(double price) {
          this.price = price;
        }
    
    
        @Override
        public String toString() {
          return name != null ? name : super.toString();
        }
    
    
        public boolean isEnableDate() {
          return enableDate;
        }
    
    
        public void setEnableDate(boolean enableDate) {
          this.enableDate = enableDate;
        }
      }
    
    
      public List<Plant> getPlants() {
        List<Plant> plants = new ArrayList<Plant>();
        plants.add(new Plant("Bloodroot", "Mostly Shady", 2.44, "03/15/2006", true));
        plants.add(new Plant("Columbine", "Shade", 9.37, "03/15/2006", true));
        plants.add(new Plant("Marsh Marigold", "Mostly Sunny", 6.81, "05/17/2006", false));
        plants.add(new Plant("Cowslip", "Mostly Shady", 9.90, "03/06/2006", true));
        plants.add(new Plant("Dutchman's-Breeches", "Mostly Shady", 6.44, "01/20/2006", true));
        plants.add(new Plant("Ginger, Wild", "Mostly Shady", 9.03, "04/18/2006", true));
        return plants;
      }
    
    
    }

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi