1. #1
    Sencha User treblereel's Avatar
    Join Date
    Mar 2010
    Location
    Moscow,Russia
    Posts
    67
    Vote Rating
    1
    treblereel is on a distinguished road

      0  

    Default TreeGridCellRenderer: The method render() is never used locally

    TreeGridCellRenderer: The method render() is never used locally


    Please Help with TreeGridCellRenderer, i am trying to add TreeGridCellRenderer to TreeGrid, but with no success. i am getting this error: The method render(ModelData, String, ColumnData, int, int, TreeStore<ModelData>, EditorTreeGrid<ModelData>) from the type new TreeGridCellRenderer<ModelData>(){} is never used locally

    Where is my mistake ?
    PHP Code:
      Folder model getTreeModel();   
           
            
    TreeStore<ModelDatastore = new TreeStore<ModelData>();   
            
    store.add(model.getChildren(), true);   
           
      
             
             
             
            
    ColumnConfig name = new ColumnConfig("name""Name"100);   

            
    name.setRenderer(new TreeGridCellRenderer<ModelData>() { 
                 
                 public 
    String render(ModelData modelString propertyColumnData configint rowIndex
                            
    int colIndexTreeStore<ModelDatastoreEditorTreeGrid<ModelDatagrid) { 

                        
    String val = (String) model.get(property); 
                         
                        
    String style =  "red"
                        return 
    "<span style='color:  " style " '>" val "</span>"


                } 
            });   
             
             
             
             
             
          
            
    TextField<Stringtext = new TextField<String>();   
            
    text.setAllowBlank(false);   
            
    name.setEditor(new CellEditor(text));   
               
            
    ColumnConfig author = new ColumnConfig("author""Author"100);   
            
    author.setEditor(new CellEditor(new TextField<String>()));   
               
            
    ColumnConfig size = new ColumnConfig("genre""Genre"100);   
            
    size.setEditor(new CellEditor(new TextField<String>()));   
           
            
    ColumnModel cm = new ColumnModel(Arrays.asList(nameauthorsize));   
           
            
    ContentPanel cp = new ContentPanel();   
            
    cp.setBodyBorder(false);   
            
    cp.setHeading("Cell TreeGrid Editing (2-Clicks)");   
            
    cp.setButtonAlign(HorizontalAlignment.CENTER);   
            
    cp.setLayout(new FitLayout());   
            
    cp.setFrame(true);   
            
    cp.setSize(600300);   
           
            
    EditorTreeGrid<ModelDatatree = new EditorTreeGrid<ModelData>(storecm);   
            
    tree.setClicksToEdit(ClicksToEdit.ONE);   
            
    tree.setBorders(true);   
            
    tree.setSize(400400);   
            
    tree.setAutoExpandColumn("name");   
            
    tree.setTrackMouseOver(false);       
             
        
    add(tree); 

  2. #2
    Sencha User treblereel's Avatar
    Join Date
    Mar 2010
    Location
    Moscow,Russia
    Posts
    67
    Vote Rating
    1
    treblereel is on a distinguished road

      0  

    Default


    ok, i have fix it but now i have no folder pics and expand/colapse buttons
    Thats wrong and how i can fix it?

    PHP Code:
            ColumnConfig name = new ColumnConfig("name""Name"100);
            

            
            
    name.setRenderer(new TreeGridCellRenderer<ModelData>(){
                @
    Override
                
    public String render(ModelData modelDataString propertyColumnData cint rowIndexint colIndex,  
                    
    ListStore<ModelDatalistStoreGrid<ModelDatatreeModelData) {  
                     
                    return 
    modelData.get(property);
                }  
              }); 

  3. #3
    Sencha - GXT Dev Team
    Join Date
    Feb 2011
    Posts
    8
    Vote Rating
    0
    warmkessel is on a distinguished road

      0  

    Default


    The reason that the Arrow's and images are removed is that when you are overriding the render method you are clobbering the layout.

    If you are trying to override the render method, you may want to start with something that looks like

    public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
    config.css = "x-treegrid-column";

    assert grid instanceof TreeGrid : "TreeGridCellRenderer can only be used in a TreeGrid";

    TreeGrid tree = (TreeGrid) grid;
    TreeStore ts = tree.getTreeStore();

    int level = ts.getDepth(model);

    String id = getId(tree, model, property, rowIndex, colIndex);
    String text = getText(tree, model, property, rowIndex, colIndex);
    AbstractImagePrototype icon = calculateIconStyle(tree, model, property, rowIndex, colIndex);
    Joint j = calcualteJoint(tree, model, property, rowIndex, colIndex);

    return tree.getTreeView().getTemplate(model, id, text, icon, false, j, level - 1);



    Alternatively if you desire is to just change the css style you might try setting a css rule to change the font color of the element. You might use FireBug and set a rule to affect the "x-grid3-td-name" class name

    J.R.

  4. #4
    Sencha - GXT Dev Team
    Join Date
    Feb 2011
    Posts
    8
    Vote Rating
    0
    warmkessel is on a distinguished road

      0  

    Default


    The reason that the Arrow's and images are removed is that when you are overriding the render method you are clobbering the layout.

    If you are trying to override the render method, you may want to start with something that looks like

    public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
    config.css = "x-treegrid-column";

    assert grid instanceof TreeGrid : "TreeGridCellRenderer can only be used in a TreeGrid";

    TreeGrid tree = (TreeGrid) grid;
    TreeStore ts = tree.getTreeStore();

    int level = ts.getDepth(model);

    String id = getId(tree, model, property, rowIndex, colIndex);
    String text = getText(tree, model, property, rowIndex, colIndex);
    AbstractImagePrototype icon = calculateIconStyle(tree, model, property, rowIndex, colIndex);
    Joint j = calcualteJoint(tree, model, property, rowIndex, colIndex);

    return tree.getTreeView().getTemplate(model, id, text, icon, false, j, level - 1);



    Alternatively if you desire is to just change the css style you might try setting a css rule to change the font color of the element. You might use FireBug and set a rule to affect the "x-grid3-td-name" class name

    J.R.

Similar Threads

  1. TreeGridCellRenderer: The method render() is never used locally
    By treblereel in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 10 Feb 2011, 6:38 AM
  2. Replies: 5
    Last Post: 16 Dec 2010, 4:12 AM
  3. how to redefined the render method of component
    By loenwang in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 16 Nov 2010, 5:31 PM
  4. is formpanel's 'render' method necessary after 'add' method??
    By BlazeCrystal in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 22 Oct 2008, 1:40 AM

Thread Participants: 1