Announcement

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

    CellRenderer and getEditorType

    I'm attempting to have some cells in a column be a drop down and some to be a text field. Similar to this post:
    http://forums.smartclient.com/showthread.php?t=5508

    I do not see the getEditorType and getEditorValueMap methods as mentioned in the solution for that post.

    Other posts that I have read make me think that I may also be able to create my own CellRenderer. However, I do not see this class or interface.

    I'm assuming that the code base has changed since those posts?
    I'm using smartGWT 2.0. How might the same thing be accomplished with this (or newer) version?

    Thanks,
    Curtis

    #2
    From this example (http://www.smartclient.com/smartgwt/showcase/#grid_cell_widgets), I was able to insert different widgets into a ListGrid by overriding the createRecordComponent method.

    However, it doesn't seem to work for a TreeGrid. My overriden method never gets called.

    Is this possible from a TreeGrid?

    Thanks,
    Curtis

    Comment


      #3
      Nevermind. I see that setShowRecordComponents(true) needed to be called.

      Comment


        #4
        Hi Curtis,

        Could you please share your solution? Did you use createRecordComponent or CellRenderer?

        thank you

        Comment


          #5
          My solution looks something like this:

          Code:
          public class SpecialTreeGrid extends TreeGrid 
          {
          	public SpecialTreeGrid()
          	{
          		this.setShowRecordComponents(true);          
          		this.setShowRecordComponentsByCell(true);  
          
          		this.setCanEdit(false);
          
          		TreeGridField nameField = new TreeGridField("Name", "Name");
          		nameField.setCanSort(false);
          		TreeGridField valueField = new TreeGridField("Value", "Value");
          		valueField.setCanSort(false);
          
          		this.setFields(nameField, valueField);
          	}
          
          	@Override
          	protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) 
          	{  
                          // create whatever canvas object you would like to display
                          // null to draw the default object
          		Canvas recComp = createRecordComponent();
          				
          		return recComp;
          	}
          }

          Comment


            #6
            Thanks for your response!
            Now I understand.. You create a non-editable grid and show there drop downs / text fields, that makes a grid always editable. Genius idea, I will try that.

            thanks again!
            Last edited by philla; 16 Nov 2010, 08:00.

            Comment

            Working...
            X