Announcement

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

    Custom Editors in ListGrid

    Hello,

    I've seen the flexibility offered by the custom editors in the Showcase Custom Editors sample http://www.smartclient.com/smartgwt/showcase/#grid_editing_custom_editors. All of these are using editors that are part of com.smartgwt.client.widgets.form.fields. I would like to create my own custom editor.

    To help you understand my requirements, here are a few examples where an editor other than those provided might be desirable:

    (a) Editing passwords - I'll want one box for the original value and a second for confirmation, as the contents will be blanked out.

    (b) Selecting options from a dropdown, where a description must be lengthy. Once selected I just want to show an indicator of what has been selected, eg "A", "B", "C", but when selecting the option I want to provide more detail, eg "A - This is what option A does", etc.

    (c) Selecting multiple items from a list - this might sound unsuitable for an editable table, but once selected the items can be represented by a comma separated list. If the list is too long to fit in the cell, it can be truncated and shown in full as a tooltip.

    I can think of two possible approaches:

    1. Extend FormItem - this is what the custom editors in the Custom Editors sample do.

    2. Use ListGrid's addCellClickHandler and a check on the column number to handle clicks on cells in the column that I wish to use my editor for and then bring up an overlay panel containing a form.

    I'm not sure if option 1 is feasible if the editor I need is not part of SmartClient. Option 2, is inconsistent with the "editable table" design pattern, as the editor won't appear inside the cell.

    Is option 1 feasible, or is there a way that I can proceed along the lines of option 2, butt putting the form inside a cell?

    Thanks,

    Andrew

    #2
    Note also option (3) Create a CanvasItem to embed any SmartClient widget (any Canvas) as a ListGrid editor.

    On those specific use cases:

    (a) this seems like something to do with two fields, as that would make validation, focus handling, etc, much easier. Rather than a custom editors, you might want to actually subclass ListGrid in order to automatically generate an extra field whenever you see a field of a certain type

    (b) would suggest just setting pickListFields to show multiple columns in the dropdown

    (c) you can do this as a SelectItem with multiple:true, the drawback is that the row expands vertically, which is a bit awkward. Something like a TextItem subclass with a FormItemIcon that launches a Menu with autoDismiss:false could handle this more cleanly.

    Comment

    Working...
    X