Announcement

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

    EditorCustomizer for Smartclient?

    Hello,

    I see this discussion where you created an EditorCustomizer for SmartGWT. Is it also available in Smartclient now? I don't see any APIs for it and I need this exact functionality.

    http://forums.smartclient.com/showthread.php?t=14023&highlight=editorType+cell

    #2
    You can use ListGridField.editorProperties to specify custom FormItem behavior for editing listGrid fields. This is the equivalent to the editorCustomizer in SmartGWT.

    Regards
    Isomorphic Software

    Comment


      #3
      Thanks, just to be clear, ListGridField.editorProperties lets you specify a unique editor at the cell level? I see that it lets you modify editor properties at the field or column level but I'm not clear from the docs how I would make an editor unique at the cell level. So, if a user makes a selection in one cell, then dynamically change the editor in the cell next to it. For example, a user has a drop-down to select a field type like Date or Number. They select Date and then the next column turns into a Date edtor. Or, if they select Number, we apply a different editor to the cell.

      Comment


        #4
        Ah- we misunderstood what you were looking for.
        In SmartClient you should be able to achieve this by creating a FormItem subclass with the properties you care about and overriding 'getEditorType()' to return the appropriate class name. That method is called for each record so allows you to provide a different editor for different rows in the grid.

        Comment


          #5
          Thanks, that works. The only thing I can't figure out is how to change the editor when the value of another cell in the row changes? I tried this and it didn't work. Any suggestions?

          Code:
          changed:function(form,item,value){
          		item.grid.redraw();
          }},

          Comment


            #6
            Hmm - a simple redraw won't recreate the form items by default (there are many cases where that would be inefficient).

            There isn't an explicit API to rebuild the edit form items, but you could achieve this by ending the edit (endEditing()) and restarting it (startEditing(...)).

            Note that if autoSaveEdits is true on your grid endEditing() will trip a save of the pending edit values.

            If this isn't the behavior you want you could potentially set autoSaveEdits to false - or if that's unacceptable in your app, you could handle this by grabbing the current set of edit values for the row (getEditValues()), then doing a "cancelEditing()" to hide the editor without saving, then pass those current values back in either via setEditValues(...) or as part of your startEditing(...) call.
            Last edited by Isomorphic; 11 Oct 2012, 09:55. Reason: added minor detail

            Comment

            Working...
            X