I'm trying to replace the context menu of the table with a left-click menu. Menu is working fine but when i try to hide and show a column of the table i get some issues:
1. i must call recalculate() on the table to make the column disappear after i set it hidden
2. column doesn't come back when i set it not hidden even if i call recalculate() or in my app code the column comes back but without header (not reproduced in this example)
this is a piece of code i use to test and shwo the result
package com.zensistemi.test.client;
import java.util.ArrayList;
import java.util.List;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.button.Button; Джумла! България - Помощен Сървър 2 (версия 1.0) - Table - Contact Category:: Table Headings: Show/Hide the Table headings (Name, Position, Email, Phone, and Fax). Position Column: Show/Hide the column displaying the contacts http://help2.joomla-bg.com/index2.php?option=com_content&t14&pop=1&page=0&Itemid=31HOME |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.table.Table;
import com.extjs.gxt.ui.client.widget.table.TableColumn;
import com.extjs.gxt.ui.client.widget.table.TableColumnMo del;
import com.extjs.gxt.ui.client.widget.table.TableItem;
import com.extjs.gxt.ui.client.widget.toolbar.AdapterTool Item;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
public class TestModule implements EntryPoint {
protected Table tbl = null;
public void onModuleLoad() {
Viewport viewport = new Viewport();
viewport.setLayout(new FitLayout());
ContentPanel cp = new ContentPanel(new FitLayout());
cp.setHeaderVisible(false);
cp.setBorders(false);
ToolBar tb = new ToolBar();
cp.setTopComponent(tb);
Button b1 = new Button("Hide"); How to: Add a Visibility Toggle to an Item (Reporting Services):: Add a visibility toggle when you want to enable a user to interactively show or hide report items or, for a table or matrix, rows and columns associated with a http://msdn.microsoft.com/en-us/library/ms156456.aspxHOME | Prince: CSS Properties:: table | prince-footnote | prince-column show | hide. float table-column-span. number | attr(colspan) table-layout. auto | fixed. table-row-span http://princexml.com/doc/6.0/properties/HOME |
b1.addSelectionListener(new SelectionListener() {
@Override
public void componentSelected(ComponentEvent ce) {
//hide column
tbl.getColumn("Symbol").setHidden(true);
tbl.recalculate();
}
});
AdapterToolItem atiB1 = new AdapterToolItem(b1);
Button b2 = new Button("Show");
b2.addSelectionListener(new SelectionListener() {
@Override
public void componentSelected(ComponentEvent ce) {
//show column
tbl.getColumn("Symbol").setHidden(false);
tbl.recalculate();
}
});
AdapterToolItem atiB2 = new AdapterToolItem(b2);
tb.add(atiB1);
tb.add(atiB2);
List columns = new ArrayList();
TableColumn col = new TableColumn("Company", 180);
col.setMinWidth(75);
col.setMaxWidth(300);
columns.add(col);
col = new TableColumn("Symbol", 75);
columns.add(col);
col = new TableColumn("Last", 75);
col.setMaxWidth(100);
col.setAlignment(HorizontalAlignment.RIGHT);
columns.add(col);
col = new TableColumn("Change", 75);
col.setAlignment(HorizontalAlignment.RIGHT);
columns.add(col);
col = new TableColumn("Last Updated", 100);
col.setAlignment(HorizontalAlignment.RIGHT);
columns.add(col);
TableColumnModel cm = new TableColumnModel(columns);
tbl = new Table(cm);
tbl.setSelectionMode(SelectionMode.MULTI);
tbl.setHorizontalScroll(true);
for (int i = 0; i < 50; i++) {
Object values = new Object[5];
values[0] = i;
values[1] = i;
values[2] = i;
values[3] = i;
values[4] = i;
TableItem item = new TableItem(values);
tbl.add(item);
}
cp.add(tbl);
viewport.add(cp);
RootPanel.get().add(viewport);
}
}
any idea what i'm doing wrong ?
Excellent!
You can hide / show a column via the TableColumn:
tbl.getColumnModel().getColumn(1).setHidden(true); Make sure to grab the latest code as there was a bug with TableView.
How much does getting a small tattoo on your hip/stomach hurt?
Do anyone else have an itchy anus? ?
|