Announcement

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

    Problem with extra field in ListGrid

    I have the following problem with ListGrid:
    - The list has 3 columns
    - One of the columns is an extra field introduced by me, and has no filtering and no sorting feature.
    - The initial layout is showed in img1.png
    - The result when I filter with the second column (write text and click filter button) is showed in img2.png
    - The result when I filter with the second column (write text, focus on thirth column and click filter button) is showed in img3.png

    As you can see, some text is showed in the "filter place" of the first column, and is different in each filtering scenario.

    The code for ListGrid is bellow.
    Tested with:
    SmartGWT 2.5
    Chrome 14 and IE 9


    Can anyone help?

    Code:
    public void onModuleLoad() {
            VLayout layout = new VLayout();
            
            ListGrid grid = new ListGrid();
            grid.setWidth(700);
            grid.setHeight(400);
            grid.setShowFilterEditor(true);
            grid.setDataSource(getDataConstructor());
            grid.fetchData();
            
            ListGridField extraField = new ListGridField("extra", "EXTRA");
            extraField.setCanFilter(false);
            extraField.setCellFormatter(new CellFormatter() {
    
                @Override
                public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                    String extra = "extra";
                    
                    if (record != null && record.getAttribute("ID") != null) {
                        extra += (rowNum + 1);
                    }
                    return "" + extra;
                }
            });
            grid.setFields(extraField, new ListGridField("ID"), new ListGridField("NAME"));
            layout.addMember(grid);
            
            RootPanel.get().add(layout);
        }
        
        public DataSource getDataConstructor() {
            DataSource ds = new DataSource();
            ds.setRecordXPath("/AGENTS/AGENT");  
            DataSourceIntegerField pkField = new DataSourceIntegerField("pk");  
            pkField.setHidden(true);  
            pkField.setPrimaryKey(true);  
      
            DataSourceTextField agentCodeField = new DataSourceTextField("ID");  
            agentCodeField.setRequired(true);  
      
            DataSourceTextField countryNameField = new DataSourceTextField("NAME");  
            countryNameField.setRequired(true);  
      
            DataSourceTextField agentNIFField = new DataSourceTextField("NIF");  
            agentNIFField.setRequired(true); 
              
            ds.setFields(pkField, agentCodeField, countryNameField, agentNIFField);  
      
            ds.setDataURL("agents.xml");  
            ds.setClientOnly(true);  
            
            return ds;
        }
    Attached Files

    #2
    Your cell formatter is being run for the cell in the FilterEditor so it is producing these mysterious values. Just ensure you return a blank string if the value is null to correct the problem.

    Comment


      #3
      Thanks for the reply.

      It works, but this solution needs to be used in a column present in the dataset.
      So, I use a dataset column and update the column content with my extra info.

      Comment

      Working...
      X