1. #1
    Ext User
    Join Date
    Jul 2010
    Location
    berlin/germany
    Posts
    20
    Vote Rating
    0
    oneTETSUO is on a distinguished road

      0  

    Default [ColumnModel]

    [ColumnModel]


    hello,

    iam using several grids and they all do the same magical miracle. when i resurf the grid/panel the height of the heading (detailed: the column model) is changed in the way that it grows stepwise in random distances.

    example (figured with firebug), inital height is 31px, next time 34px, then 38px, then 41px, then 48px. (i didnt observed it often coz i dont have a clue, where that change is coming from...)

    i could find a method to set or override the height of the describing grid, so iam a bit helpless with this.

    code or screenshot needet ?

    gxt.2.2.0
    gwt 2.0.4
    google app engine 1.3.7 (same on production site with tomcat 6.0.29)
    Last edited by oneTETSUO; 7 Oct 2010 at 7:06 AM. Reason: software versions

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Yes, a testcase that implements EntryPoint and demonstrates this is needed.

  3. #3
    Ext User
    Join Date
    Jul 2010
    Location
    berlin/germany
    Posts
    20
    Vote Rating
    0
    oneTETSUO is on a distinguished road

      0  

    Default


    hello,

    the used example is strictly based on the mail-sample. from the entrypoint to this portlet is a long way. i have the issue with these height-magic on every portlet. i also used it on a plain layoutcontainer and got the same results.


    the controller which delegates the event to the view/gui

    Code:
    public class ReportController extends Controller {
    
    	private ReportServiceAsync reportService		= null;
    	private SystemServiceAsync systemService	= null;
    	private ReportFolderView folderView		= null;
    	private ReportView reportView			= null;
    	private LogInfo logInfo				= null;
    	private final int timeOut				= 500;
    	private Timer timer				= null;	
    	private final int refreshTimer			= 12000;
    
    public ReportController() {
    		registerEventTypes		( AppEvents.Init );
    		registerEventTypes		( AppEvents.NavReport );
    		registerEventTypes		( AppEvents.ViewReportItems );
    		registerEventTypes		( AppEvents.ViewReportItem );
    		logInfo 				= new LogInfo();
    		logInfo.setClazz			( ReportController.class.getName() );
    	}
    
    	@Override
    	public void handleEvent( final AppEvent event ) {
    		final EventType type = event.getType();
    		if (type == AppEvents.Init) {			
    			forwardToView(folderView, event);
    		} else if (type == AppEvents.NavReport) {			
    			forwardToView(folderView, event);
    			forwardToView(reportView, event);
    		} else if (type == AppEvents.ViewReportItems) {
    			setTimer(event);
    			onViewLoadLiveReportItems(event);
    		} else if (type == AppEvents.ViewReportItem) {
    			forwardToView(reportView, event);
    		}
    	}
    
    	private void setTimer( final AppEvent event ){
    		logThis("create report-timer with :" + refreshTimer + " ms.");
    		final Folder f 	= event.getData();		
    		timer			= new Timer() {
    			public void run() {
    				final AppEvent ae = new AppEvent( AppEvents.ViewReportItems, f );
    				ae.setData("folder", f);
    				onViewLoadLiveReportItems(ae);
    			}
    		};
    	}
    
    	private void onViewLoadLiveReportItems( final AppEvent event ) {
    		final Folder f 			= event.getData();
    		timer.schedule			( refreshTimer );
    		logThis				( "eventfoldername: " + f.getName() );
    		Map<String,Model> mandateUser = (Map<String,Model>) Registry.get( Liveview.MANDATEUSER );
    		Iterator<Model> userIt = mandateUser.values().iterator();
    		UserInfoTransferData userInfo = null;
    		while (userIt.hasNext())
    			userInfo = userIt.next();
    				
    		if (f != null) {
    			reportService.getLiveFile(userInfo, new AsyncCallback<List<ReportTable>>() {
    				public void onSuccess( final List<ReportTable> result ) {
    
    					if (result.get(0).getReportTableList() != null){
    					logThis("received report with " + result.get(0).getReportTableList().size() + " entries.");
    					final AppEvent ae = new AppEvent(event.getType(), result);
    					ae.setData("folder", f);
    					forwardToView(reportView, ae);
    					} else {
    						final AppEvent ae = new AppEvent( event.getType(), event.getData() );
    					}
    				}
    
    				public void onFailure(Throwable caught) {
    					Dispatcher.forwardEvent( AppEvents.Error, caught );
    				}
    			});
    		}
    	}
    
    	@Override
    	public void initialize() {
    		super.initialize		(  );
    		systemService		= ( SystemServiceAsync ) Registry.get( Liveview.SYSTEMSERVICE );
    		reportService		= ( ReportServiceAsync ) Registry.get( Liveview.REPORTSERVICE );
    		folderView		= new ReportFolderView(this);
    		reportView		= new ReportView(this);
    		logThis			( "successfully created reportController" );
    	}
    
    	private void logThis( final String message ){
    		final String myMessage	= message; 
    		logInfo.setMessage	( myMessage );
    		systemService.writeLog	( logInfo, new AsyncCallback<LogInfo>() {
    			public void onSuccess( final LogInfo result ) {
    				logInfo.setLogged( false );
    			}
    			public void onFailure( final Throwable caught ) {
    				logInfo.setLogged( false );
    				final Timer t = new Timer() {
    					public void run() {
    						logThis(myMessage);
    					}
    				};
    				t.schedule( timeOut );
    			}
    		});
    	}
    }
    the view, which instanciate the portal and portlet

    Code:
    public class ReportView extends View {
    
    	private ContentPanel container 					= null;
    	private ReportSummaryPanel reportSummaryPanel			= null;
    	private ReportTableRow tableRow					= null;
    	private List<ReportSiteStatistics> summaryList			= null;
    	private LayoutContainer westContainer				= null;
    	private Grid<ReportTableRow> reportResultGrid 			= null;
    	private Grid<ReportSiteStatistics> reportSummaryGrid		= null;
    	public static final String REPORTSUMMARYPANEL			= "reportSummaryPanel";
    
    	public ReportView( final Controller controller ) {
    		super(controller);
    	}
    
    	/**
    	 * default initializer
    	 */
    	@Override
    	protected void initialize() {
    		super.initialize				(  );
    		
    		container 				= new ContentPanel();	
    		container.setLayout			( new RowLayout() );
    		container.setShadow			( true );
    		container.setTitleCollapse		( true );
    		container.setHeaderVisible		( false );
    		container.setLayoutOnChange		( true );
    		container.setExpanded			( true );
    		container.setMonitorWindowResize	( true );
    		container.setBodyBorder			( true );
    		container.addListener			( Events.Resize, createResizeListener() );
    		
    		final Portal portal 			= new Portal(1);
    		container.add				( portal );
    
    		reportSummaryPanel			= new ReportSummaryPanel();
    		reportSummaryPanel.addListener		( Events.Resize, createResizeListener() );
    		portal.add				( reportSummaryPanel, 0 );
    		Registry.register				( REPORTSUMMARYPANEL, reportSummaryPanel );
    	}
    
    	/**
    	*viewhelper is used for windowresize and stuff like that, should not take effect on the embedded grid
    	*/
    	private Listener<? extends BaseEvent> createResizeListener(){
    		return new Listener<ComponentEvent>() {
    			@Override
    			public void handleEvent( final ComponentEvent event ) {
    				ViewHelper vh = new ViewHelper();
    				vh.reRenderPortlets();
    			}
    		};
    	}
    
    	@Override
    	protected void handleEvent( final AppEvent event ) {
    		try {
    			if (event.getType() == AppEvents.NavReport) {
    				westContainer			= (LayoutContainer) Registry.get(AppView.CENTER_PANEL);
    				westContainer.removeAll		(  );
    				westContainer.add		( container );
    				westContainer.layout		(  );
    				return;
    			}
    
    			if (event.getType() == AppEvents.ViewReportItems ){ //|| event.getType() == AppEvents.UpdateReport{
    				final Folder f 				= (Folder) event.getData("folder");
    				reportListPanel.setHeading		( f.getName() );	
    				this.fillSummaryGrid			( event );
    				return;
    			}
    
    			if (event.getType() == AppEvents.ViewReportItem) {
    				if (event.getData()!=null){
    					/* code here */ 
    				}
    				return;
    			}
    		} catch (Exception e) {
    			StringBuffer sb 		= new StringBuffer();
    			sb.ensureCapacity	(8192);
    			for (StackTraceElement ste : e.getStackTrace()){
    				sb.append	(ste.getFileName());
    				sb.append	("&nbsp;");
    				sb.append	(ste.getLineNumber());
    				sb.append	("&nbsp;");
    				sb.append	(ste.getClassName());
    				sb.append	("<br>");
    			}
    			Dispatcher.forwardEvent( AppEvents.Error, sb.toString().trim() );
    		}
    	}
    
      private void fillSummaryGrid( final AppEvent event ){
    		reportSummaryGrid 			= reportSummaryPanel.getGrid();
    		reportSummaryGrid.getStore().removeAll	(  );
    		final List<ReportTable> reportList		= event.getData();			
    		final ReportTable table			= reportList.get( 0 );
    		summaryList				= table.getReportSiteStatistics();
    		if (summaryList!=null && summaryList.size() > 0) {
    			for (ReportSiteStatistics reportTableTransferData : summaryList) {
    				reportSummaryGrid.getStore().add ( reportTableTransferData );
    			}
    			reportSummaryGrid.setHeight	( 55 );
    			lastReadDate 			= ( table.getReadTime() );
    			reportSummaryPanel.setHeading	( "Summary List - last read: " + lastReadDate.toString() );
    
    		} else {
    			Info.display			("Info", "last server result was empty");
    		}
    	}
    }
    the portlet within the grid

    Code:
    public class ReportSummaryPanel extends Portlet {
    
    	private final Grid<Model> grid;
    	private final ListStore<Model> store;
    	private final ColumnModel cm;
    	private final int margin = 45;
    
      public ReportSummaryPanel(  ) {
    		super 				(  );
    		setLayout 			( new FlowLayout() );
    		setCollapsible			 ( true );
    		setAnimCollapse			( true );
    		setHeaderVisible			( true );
    		setMonitorWindowResize 		( true );
    		setScrollMode 			( Style.Scroll.AUTOY );
    		setExpanded 			( true );		
    		setMonitorWindowResize		( true );
    		setStateId			( "reportSummaryPanel" );
    		
    		cm 				= new ColumnModel( createColumnConfigs() );	
    		
    		store 				= new ListStore<Model>();
    			
    		grid 				= new Grid<Model>(store, cm);
    		grid.getView().setForceFit 	( true );		
    		grid.getView().setAutoFill	( true );
    		grid.getView().setSortingEnabled ( false );
    		grid.setAutoExpandColumn 	( "col1" );
    		grid.setStripeRows 		( true );
    		grid.setLoadMask 		( true );
    
    		grid.focus 			(  );
    		grid.setColumnLines 		( true );
    		
    		add 				( grid );
      }
    
      @Override
      protected void afterRender(){
    
    		ContentPanel centerPanel 	= (ContentPanel) this.getParent().getParent().getParent();
    		final int innerWidth 		= centerPanel.getInnerWidth()-margin;
    		centerPanel.syncSize		(  );
    		centerPanel.repaint		(  );
    		syncSize			(  );
    		layout				(  );
    		this.getGrid().setWidth		( innerWidth );
    		this.getGrid().syncSize		(  );
    		this.getGrid().repaint		(  );				
      }
    
      private List<ColumnConfig> createColumnConfigs(){
    
    		final List<ColumnConfig> configs		= new ArrayList<ColumnConfig>();
    
    		ColumnConfig columnConfig 		= new ColumnConfig	( "col1", "col1", 45 );
    		columnConfig.setToolTip			( "col1" );
    		columnConfig.setAlignment		( HorizontalAlignment.CENTER );
    		columnConfig.setSortable		( false );
    		configs.add				( columnConfig );  
    
    		columnConfig 				= new ColumnConfig	( "col2","col2", 45 );
    		columnConfig.setToolTip			( "col2" );
    		columnConfig.setAlignment		( HorizontalAlignment.CENTER );
    		columnConfig.setSortable		( false );
    		configs.add				( columnConfig );  
    
    		columnConfig 				= new ColumnConfig	( "col3", "col3", 45 );  
    		columnConfig.setToolTip			( "col3" );
    		columnConfig.setAlignment		( HorizontalAlignment.CENTER );
    		columnConfig.setSortable		( false );
    		configs.add				( columnConfig ); 		
    
    		columnConfig 				= new ColumnConfig	( "col4", "col4", 45 );  
    		columnConfig.setToolTip			( "col4" );
    		columnConfig.setAlignment		( HorizontalAlignment.CENTER );
    		columnConfig.setSortable		( false );
    		configs.add				( columnConfig );
    
    		columnConfig 				= new ColumnConfig	( "col5","col5", 45 );  
    		columnConfig.setToolTip			( "col5" );
    		columnConfig.setAlignment		( HorizontalAlignment.CENTER );
    		columnConfig.setSortable		( false );		
    		configs.add				( columnConfig );
    		
    		columnConfig 				= new ColumnConfig	( "col6", "col6", 45 );  
    		columnConfig.setToolTip			( "col6" );
    		columnConfig.setAlignment		( HorizontalAlignment.CENTER );
    		columnConfig.setSortable		( false );
    		configs.add				( columnConfig );
    		
    		columnConfig 				= new ColumnConfig	( "col7", "col7", 45 );  
    		columnConfig.setToolTip			( "col7" );
    		columnConfig.setAlignment		( HorizontalAlignment.CENTER );
    		columnConfig.setSortable		( false );
    		configs.add				( columnConfig );
    		
    		columnConfig 				= new ColumnConfig	( "col8", "col8", 45 );  
    		columnConfig.setToolTip			( "col8" );
    		columnConfig.setAlignment		( HorizontalAlignment.CENTER );
    		columnConfig.setSortable		( false );
    		configs.add				( columnConfig );
    		
    		return configs;
    	}
    
      public ListStore<Model> getStore() {
    		return store;
      }
    
      public Grid<Model> getGrid() {
    		return grid;
      }
    }
    if you want testable junit code or sthg, i need to snip that out of the code and could post it on monday, as it will need some time to get it running. you may have such cases in petto. anyhow, the setup of the grid itself or the columnmodel is maybe not complete, that was the message in the back of my head ....

    edit: when the panel is collapsed, the changes are not happen (frozen state/height), if the panel is decollapsed/visible, the magic takes place :/

Similar Threads

  1. Clearing the ColumnModel
    By dreamcaster in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 6 Jan 2010, 8:36 PM
  2. [SOLVED] Help with the ColumnModel
    By mpatel in forum Ext 2.x: Help & Discussion
    Replies: 13
    Last Post: 22 Jan 2009, 8:29 PM
  3. ColumnModel Confusion
    By RPow in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 25 Jul 2008, 6:43 AM
  4. Bug in ColumnModel
    By Animal in forum Ext 1.x: Bugs
    Replies: 4
    Last Post: 25 Sep 2007, 7:38 AM

Thread Participants: 1