Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    [BUG] CellRecordComponents are not always shown in a TreeGrid

    Hello,

    I've found the following strange bug in SmartGWT 4.0p (latest nightly (29.08.2013)):
    If the records of a TreeGrid have CellRecordComponents and a Node is Expanded the CellRecordComponent is not always shown (reproducable).

    - This only happens with Datasources beeing NOT client-only
    - This only happens in 4.0p not in 3.1p (tried the latest nightly (29.08.2013))
    - This could be reproduced in Chrome and Firefox both up to date (I've not testet it in other browsers yet)

    Here is the code for reproducing the problem:

    Code:
    @Override
    public void onModuleLoad() {
    
    	TreeGrid treeGrid = new TreeGrid() {
    		@Override
    		protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {
    			if (!"actions".equals(getFieldName(colNum))) {
    				return null;
    			}
    			ImgButton button = new ImgButton();
    			button.setShowRollOver(true);
    			button.setShowDown(false);
    			button.setSrc("[SKIN]/actions/add.png");
    			button.setHeight(16);
    			button.setWidth(16);
    			return button;
    		}
    	};
    	treeGrid.setShowRecordComponents(true);
    	treeGrid.setShowRecordComponentsByCell(true);
    	treeGrid.setWidth(500);
    	treeGrid.setHeight(400);
    	treeGrid.setLoadDataOnDemand(true);
    
    	DataSource ds = new DataSource() {
    		{
    			setID("test");
    			setDataProtocol(DSProtocol.CLIENTCUSTOM);
    			setDataFormat(DSDataFormat.CUSTOM);
    			DataSourceField parent = new DataSourceField("parent", FieldType.INTEGER);
    			parent.setForeignKey("test.id");
    			DataSourceField id = new DataSourceField("id", FieldType.INTEGER);
    			id.setPrimaryKey(true);
    			setFields(id, parent);
    		}
    
    		@Override
    		protected Object transformRequest(DSRequest request) {
    			DSResponse response = new DSResponse(request.getDataSource());
    			response.setStatus(0);
    
    			Criteria crit = new Criteria(request.getData());
    			Integer parent = crit.getAttributeAsInt("parent");
    			Record[] data = new Record[5];
    			for (int i = 0; i < data.length; i++) {
    				data[i] = creatCat(parent == null ? 1 : parent, i);
    			}
    			response.setData(data);
    			processResponse(request.getRequestId(), response);
    			return null;
    		}
    
    		private Record creatCat(int parent, int count) {
    			Record record = new Record();
    			record.setAttribute("parent", parent);
    			record.setAttribute("id", parent * 10 + count);
    			return record;
    		}
    	};
    
    	treeGrid.setDataSource(ds);
    	treeGrid.setAutoFetchData(true);
    
    	treeGrid.setFields(
    			new TreeGridField("id"),
    			new TreeGridField("actions", " ", 60)
    	);
    
    	treeGrid.draw();
    }
    You have to expand the 1st node. In 3.1p every new displayed child node will have an button as CellComponent, in 4.0p there will be the first four Buttons missed.

    regards
    Andreas
    Last edited by andy.2003; 30 Aug 2013, 06:13. Reason: changed version from 4.1p to 4.0p (which I have tested with)

    #2
    @Isomorphic: is it possible that you can take a look at this strange behavior?

    Comment


      #3
      It's assigned to be looked at, no ETA as yet - we'll update this thread when it's been fixed

      Comment


        #4
        Originally posted by Isomorphic View Post
        It's assigned to be looked at, no ETA as yet - we'll update this thread when it's been fixed
        has there been any progess on this thread?

        Comment


          #5
          We made some changes to address this issue some time ago. Have you retested with a recent nightly build?

          Comment


            #6
            Hello,

            I have retested the bug with the latest nightly (06.12.2013) but the bug still exists. The code in the first post is runs well, but if the Datasource-response is delayed you will still get this strange behaviour.

            Here is an updated testcase:

            Code:
            	public void onModuleLoad() {
            
            		TreeGrid treeGrid = new TreeGrid() {
            			@Override
            			protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {
            				if (!"actions".equals(getFieldName(colNum))) {
            					return null;
            				}
            				ImgButton button = new ImgButton();
            				button.setShowRollOver(true);
            				button.setShowDown(false);
            				button.setSrc("[SKIN]/actions/add.png");
            				button.setHeight(16);
            				button.setWidth(16);
            				return button;
            			}
            		};
            		treeGrid.setShowRecordComponents(true);
            		treeGrid.setShowRecordComponentsByCell(true);
            		treeGrid.setWidth(500);
            		treeGrid.setHeight(400);
            		treeGrid.setLoadDataOnDemand(true);
            
            		DataSource ds = new DataSource() {
            			{
            				setID("test");
            				setDataProtocol(DSProtocol.CLIENTCUSTOM);
            				setDataFormat(DSDataFormat.CUSTOM);
            				DataSourceField parent = new DataSourceField("parent", FieldType.INTEGER);
            				parent.setForeignKey("test.id");
            				DataSourceField id = new DataSourceField("id", FieldType.INTEGER);
            				id.setPrimaryKey(true);
            				setFields(id, parent);
            			}
            
            			@Override
            			protected Object transformRequest(DSRequest request) {
            				final DSResponse response = new DSResponse(request.getDataSource());
            				final JavaScriptObject requestData = request.getData();
            				final String requestId = request.getRequestId();
            				new Timer() {
            					@Override
            					public void run() {
            						response.setStatus(0);
            
            						Criteria crit = new Criteria(requestData);
            						Integer parent = crit.getAttributeAsInt("parent");
            						Record[] data = new Record[5];
            						for (int i = 0; i < data.length; i++) {
            							data[i] = creatCat(parent == null ? 1 : parent, i);
            						}
            						response.setData(data);
            
            						processResponse(requestId, response);
            					}
            				}.schedule(500);
            				return null;
            			}
            
            			private Record creatCat(int parent, int count) {
            				Record record = new Record();
            				record.setAttribute("parent", parent);
            				record.setAttribute("id", parent * 100 + count);
            				return record;
            			}
            		};
            
            		treeGrid.setDataSource(ds);
            		treeGrid.setAutoFetchData(true);
            
            		treeGrid.setFields(
            				new TreeGridField("id"),
            				new TreeGridField("actions", " ", 60)
            		);
            
            		treeGrid.draw();
            	}

            Comment


              #7
              @isomorphic: is there any work on this issue?

              Comment


                #8
                It's assigned to be looked at - no ETA, but we'll update this thread when we have more information

                Comment


                  #9
                  This has been fixed and has already hit nightly builds. Please retest with the latest from smartclient.com/builds.

                  Comment


                    #10
                    Perfect now it works!

                    Comment

                    Working...
                    X