GIGJ.COM
welcome to my space
X
Search:  
Welcome to:gigj.com
 HOME   Show/Hide table column
Show/Hide table column
Published by: rose 2010-03-13

  • 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;
    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");
    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 ?


  • 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.


  • Excellent!





  • Nortel Unveils Vision, Strategy for Israeli High-Performance Net
    Busy Friday Leads to Strong Close for Net Stocks

    PRINT Add to favorites
  • fast video playback
  • library scrape problem
  • install xbmc on ubuntu 8 04 base with samba and imon pad and vdf no gdm
  • bug cant change downloaded information for tv series
  • quick question about full screen
  • video play judders
  • problems with external display lcdproc and futaba dm140
  • please insert disk
  • disturbed digital sound after pausing track
  • changing from own compiled to atlantis beta1
  • bug wrong share disappear in browse for new share dialog
  • cheap remote for xbmc
  • calsadirectsound errors in intrepid
  • bug maybe cant shut down the computer

  • problem with dell remote control
  • xbmc svn ubuntu 8 10 projectm sluggish
  • invalid and inefficient vfw avi packed b frames detected
  • changing the kernel
  • can t add specify raid array for source of media
  • how do i install xbmc for linux under ubuntu
  • start xbmc from apache webserver
  • x64 ubuntu browsing samba crashes xbmc x86 is ok
  • xbox dvd dongle
  • problem with osk
  • xbmc hangs on splash 1080p
  • using xbmc over remote x session
  • ubuntu 8 10 and the xorg conf
  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Show/Hide table column , Please add it free.
    About us |Contact us |Advertisement |Site map |Exchange links
    Copyright© 2008gigj.com All Rights Reserved