PDA

View Full Version : [FIXED] When Column in Grid is hidden, editor doesn't adjust



nbuesing
23 Jan 2012, 1:07 PM
If I hide a column (columnModel.getColumn(1).setHidden(true), the editor no longer shows up over the cell as expected, instead it still renders as though the column wasn't hidden (so it ends up being rendered, in this case, straddling 1/2 of the column it is editing and 1/2 of the next column.

See screenshots.

30918

30919

nbuesing
23 Jan 2012, 8:41 PM
Here is a patch to the GridInlineEditor so hidden columns are taken into account.



### Eclipse Workspace Patch 1.0
#P Ext GWT
Index: com.sencha.gxt.ui/src/main/java/com/sencha/gxt/widget/core/client/grid/editing/GridInlineEditing.java
===================================================================
--- com.sencha.gxt.ui/src/main/java/com/sencha/gxt/widget/core/client/grid/editing/GridInlineEditing.java (revision 2068)
+++ com.sencha.gxt.ui/src/main/java/com/sencha/gxt/widget/core/client/grid/editing/GridInlineEditing.java (working copy)
@@ -19,10 +19,10 @@
import com.sencha.gxt.widget.core.client.ComponentHelper;
import com.sencha.gxt.widget.core.client.event.BeforeStartEditEvent;
import com.sencha.gxt.widget.core.client.event.BlurEvent;
+import com.sencha.gxt.widget.core.client.event.BlurEvent.BlurHandler;
import com.sencha.gxt.widget.core.client.event.CancelEditEvent;
import com.sencha.gxt.widget.core.client.event.CompleteEditEvent;
import com.sencha.gxt.widget.core.client.event.StartEditEvent;
-import com.sencha.gxt.widget.core.client.event.BlurEvent.BlurHandler;
import com.sencha.gxt.widget.core.client.form.CheckBox;
import com.sencha.gxt.widget.core.client.form.Field;
import com.sencha.gxt.widget.core.client.form.TriggerField;
@@ -233,7 +233,9 @@

int left = 0;
for (int i = 0; i < cell.getCol(); i++) {
- left += getEditableGrid().getColumnModel().getColumnWidth(i);
+ if (!getEditableGrid().getColumnModel().isHidden(i)) {
+ left += getEditableGrid().getColumnModel().getColumnWidth(i);
+ }
}

field.getElement().setLeftTop(left, row.getOffsetTop());

nbuesing
26 Apr 2012, 10:23 AM
I have reported this bug a long time ago (to where i have forgotten about it). I removed my work around in my code and I see the issue still exists.

This is a simple fix (and even provided patch file on how to fix it).

Please provide feedback on this, it should be part of the 3.0 release IMHO.

gdlm
26 Apr 2012, 11:04 PM
There's probably a relation with this issue (http://www.sencha.com/forum/showthread.php?198027-Inline-editing-cell-don-t-hide-while-resizing-column.)

darrellmeyer
28 Apr 2012, 8:08 AM
Fixed in SVN (rev 2727).

Fix can be seen here http://staging.sencha.com:8080/examples-dev/#ExamplePlace:inlineeditablegrid

WesleyMoy
3 May 2012, 9:37 AM
The fix for this bug has been included in the public release of Sencha GXT 3.0.0. You should now see the fix included in the Sencha GXT 3.0.0 Explorer demo (http://www.sencha.com/examples/).

Firelight
23 Jul 2013, 10:59 PM
The bug matters in case of initial render with initially hidden column.
GXT 3.0.1GPL

Maybe a workaround exists?

Colin Alworth
24 Jul 2013, 6:26 AM
According to earlier remarks, this was fixed in 3.0.0, which is before 3.0.1. Can you provide a working test case that demonstrates the issue you are having? It might be a different one than what was originally fixed here.

Firelight
24 Jul 2013, 11:17 PM
Here it is. It renders the hidden field content even.


package client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.RootPanel;
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.button.TextButton;
import com.sencha.gxt.widget.core.client.container.CardLayoutContainer;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
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 java.util.ArrayList;
import java.util.List;


public class TestEntryPoint implements EntryPoint {


private static final SampleProperties props = GWT.create(SampleProperties.class);


public void onModuleLoad() {
RootPanel panel = RootPanel.get();
final CardLayoutContainer card = new CardLayoutContainer();
TextButton btn = new TextButton("Click me!");
btn.addSelectHandler(new SelectEvent.SelectHandler() {
@Override
public void onSelect(SelectEvent selectEvent) {
List<ColumnConfig<Sample, ?>> cols = new ArrayList<ColumnConfig<Sample, ?>>();
ColumnConfig<Sample, String> col = new ColumnConfig<Sample, String>(props.address(), 100, "Address");
col.setHidden(true);
cols.add(col);


col = new ColumnConfig<Sample, String>(props.name(), 100, "Name");
cols.add(col);


Grid<Sample> grid = new Grid<Sample>(new ListStore<Sample>(props.id()), new ColumnModel<Sample>(cols));
grid.getStore().add(new Sample(1, "SampleName", "SampleAddress"));
card.add(grid);
card.setActiveWidget(grid);
}
});
panel.add(card);
panel.add(btn);
}


interface SampleProperties extends PropertyAccess<Sample> {
ModelKeyProvider<Sample> id();


ValueProvider<Sample, String> name();
ValueProvider<Sample, String> address();
}


class Sample {
private int id;
private String name;
private String address;


public Sample(int id, String name, String address) {
this.id = id;
this.name = name;
this.address = address;
}


String getAddress() {
return address;
}


void setAddress(String address) {
this.address = address;
}


int getId() {
return id;
}


void setId(int id) {
this.id = id;
}


String getName() {
return name;
}


void setName(String name) {
this.name = name;
}
}
}