PDA

View Full Version : Inline editting and text button



paucarre
5 Mar 2012, 7:09 AM
In a inline editable grid if the user clicks in a button that is contained inside a cell, the grid should not start the editing mode. In this case ,the user just wants to click the button, not edit the row.
I am using text button for this.

sven
5 Mar 2012, 7:10 AM
The Grid starts only editing, if you have setup an editor. Is this the case?

Just having a TextButtonCell should not start editing, if there is no editor defined.

paucarre
5 Mar 2012, 7:16 AM
Yes, I have an editing set up because I need to edit other columns of the row, but I dont need to edit the columns where there is a button.

sven
5 Mar 2012, 7:19 AM
Editors are setup for each column. If you press your button and an editor shows up for that column it should indicate, that you also setup an editor for that column.

If that is not the case, please provide a fully working testcase implementing EntryPoint.

paucarre
5 Mar 2012, 7:53 AM
The problem is with GridRowEditing
Here you have the code:




/**
* Ext GWT 3.0.0-beta3 - Ext for GWT
* Copyright(c) 2007-2011, Sencha, Inc.
* licensing@sencha.com
*
* http://sencha.com/license
*/
package com.oghmasys.nomad.gui.client;


import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;


import com.google.gwt.cell.client.DateCell;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.editor.client.Editor.Path;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
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.IsWidget;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.oghmasys.nomad.gui.client.event.ExecuteActionEvent;
import com.oghmasys.nomad.gui.client.model.CrudRowModel;
import com.oghmasys.nomad.gui.client.widget.CrudDataValueProvider__CRUD;
import com.sencha.gxt.cell.core.client.SimpleSafeHtmlCell;
import com.sencha.gxt.cell.core.client.TextButtonCell;
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.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.BeforeStartEditEvent.BeforeStartEditHandler;
import com.sencha.gxt.widget.core.client.event.CancelEditEvent.CancelEditHandler;
import com.sencha.gxt.widget.core.client.event.CompleteEditEvent.CompleteEditHandler;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.event.StartEditEvent.StartEditHandler;
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.Field;
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.editing.GridEditing;
import com.sencha.gxt.widget.core.client.grid.editing.GridInlineEditing;
import com.sencha.gxt.widget.core.client.grid.editing.GridRowEditing;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;


public class GridRowEditingExample implements IsWidget, EntryPoint {


@Override
public Widget asWidget() {

TextButtonCell button = new TextButtonCell();
button.setText("AA");

ColumnConfig<String, String> cc1 = new ColumnConfig<String, String>(
new ValueProvider<String, String>() {
@Override
public String getValue(String object) {
return "A";
}


@Override
public void setValue(String object, String value) {


}


@Override
public String getPath() {
return "";
}


});
cc1.setCell(button);
List<ColumnConfig<String, ?>> l = new ArrayList<ColumnConfig<String, ?>>();
l.add(cc1);


ColumnModel<String> cm = new ColumnModel<String>(l);


final ListStore<String> store = new ListStore<String>(
new ModelKeyProvider<String>() {


@Override
public String getKey(String item) {
return "A";
}
});
List<String> list = new LinkedList<String>();
list.add("A");
store.addAll(list);


Grid<String> grid = new Grid<String>(store, cm);
grid.getView().setAutoExpandColumn(cc1);


// EDITING//
final GridEditing<String> editing = new GridRowEditing<String>(grid);


// EDITING//
FramedPanel cp = new FramedPanel();
cp.setHeadingText("Editable Grid Example");
cp.setPixelSize(600, 400);
cp.addStyleName("margin-10");


VerticalLayoutContainer con = new VerticalLayoutContainer();
con.setBorders(true);
con.add(grid, new VerticalLayoutData(1, 1));


cp.setWidget(con);


cp.setButtonAlign(BoxLayoutPack.CENTER);


return cp;
}


@Override
public void onModuleLoad() {
RootPanel.get().add(asWidget());
}
}




GridRowEditingExample gridRowEditingExample = new GridRowEditingExample();
RootPanel.get().add(gridRowEditingExample.asWidget());

sven
5 Mar 2012, 7:56 AM
GridRowEditing is not inline editing.

You will need to listen to the BeforeStartEditEvent event and cancel it for your specific cell.