Announcement

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

    Row height does not accomodate RecordComponent

    I'd like to use the override of createRecordComponent on a ListGrid to embed a DynamicForm in one of the columns. The form shows up, but the row height is still the standard height so you can't see the complete form, even though I've setFixedRecordHeights(false). I'd like the row height to auto fit to the form height since not every row will have the exact same form.

    #2
    This seems to be working fine. It might be a small mistake like having code that sets fixedRecordHeights back to true? If not, try creating a test case.

    Comment


      #3
      This sample has a nested form and works fine.

      Sanjiv

      Comment


        #4
        The sample uses getExpansionComponent which is the technique I've switched over to and I think will ultimately make for a better solution anyway.

        I was originally trying to override createRecordComponent and have the form show up in a cell of the main ListGrid row instead of having a separate expansion section. I still may want to try that on another screen so it would be nice to know if it is possible, or is createRecordComponent expected to return a Canvas that will fit in the predetermined row height?

        Comment


          #5
          Both styles (fitting to row or having row expand) are supported, controlled by EmbeddedPosition.

          Comment


            #6
            here is the example that demonstrates the problem:

            Code:
                public void onModuleLoad() {
                    TreeGrid grid = new TreeGrid(){
                    
            
                        @Override
                        protected Canvas createRecordComponent(ListGridRecord record,
                                Integer colNum) {
                            String fieldName = getFieldName(colNum);
                            if (fieldName.startsWith("c")) {    
                                Label label = new Label("CANVAS");
                                label.setWidth100();
                                label.setHeight(100);
                                label.setBorder("2px solid blue");
                                return label;
                            } else {
                                return null;
                            }
                            
                        }
                        
                    };
                    
                    
                    ArrayList<TreeGridField> fields = new ArrayList<TreeGridField>();
                    
                    fields.add(new TreeGridField("label", "Label"));
                    for (int i=0; i<2; i++) {
                        fields.add(new TreeGridField("c"+i, "COL "+i));
                    }
            
            
                    grid.setShowRecordComponents(true);          
                    grid.setShowRecordComponentsByCell(true);
                    grid.setFields(fields.toArray(new ListGridField[fields.size()]));
                    grid.setWidth(600);
                    grid.setFixedRecordHeights(false);
            
                    Tree tree = new Tree();
                    tree.setModelType(TreeModelType.PARENT);
                    tree.setNameProperty("label");
                    tree.setIdField("id");
                    tree.setParentIdField("parentId");
                    tree.setRootValue(0);
                    
                    
                    
                    grid.setShowRoot(false);        
                    grid.setData(tree);
                
                    TreeNode rootNode = grid.getTree().getRoot();
                    tree.add(createNode("label1", 1, 0), rootNode);
                    tree.add(createNode("label2", 2, 0), rootNode);
                    
                    grid.setHeight100();
                    grid.draw();
                    
                    
                }
                
                public TreeNode createNode(String label, int id, int parentId) {
                    TreeNode node = new TreeNode();
                    node.setAttribute("label", label);
                    node.setAttribute("id", id);
                    node.setAttribute("parentId", parentId);
                    return node;
                }
                
            }
            Tested with SmartGwt 2.2 and FireFox 3.5.x
            The code produces the layout as the attached screenshot. You can notice that blue boxes overlap, but they should not, i.e. row height should expand to accommodate the box height.
            Same happens if I try with ListGrid instead of TreeGrid.

            Am I doing something wrong?

            Best,

            Predrag
            Attached Files
            Last edited by pedjak; 22 Jun 2010, 17:55.

            Comment


              #7
              Hai

              If you override the createRecordComponent on a listgrid for two cells,and if you drag or resize the columns , will it overlap? In my test case, it's overlapping... Is there any solution?

              Comment

              Working...
              X