Announcement

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

    Custom DataSourceField in ListGrid

    Hi,

    How can I create a ListGrid to use a custom DataSourceField?

    What I did was:
    1) Created a custom Widget
    2) Created a custom DataSourceField (CustomDataSourceField that extends DataSourceField and set some custom atributes)
    3) Created a DataSource with one of the fields as a instance of this CustomDataSourceField
    4) Created a ListGrid setting the datasource to the DataSource create on step 3.

    Now what I want to do:
    When editing a cell that is bounded to a customdatasourcefield, it shall automatically use the custom widget for editing.

    I don't want to set manually the ListGridFIelds, and then calling the setEditorType() method of the ListGridField when building the Grid, because I want only to create the DataSource (because latter I will reuse the same datasource also in a DynamicForm)

    To accomplish that, I'm trying to extend the ListGrid to a CustomListGrid that supports the CustomDataSourceField, but I don't know when to "intercept" the ListGrid so I can force the use of my CustomWidget for editing.

    Thanks,
    Cerávolo

    #2
    All unnecessary. Use DataSourceField.setEditorType().

    Comment


      #3
      Using the datasourcefield.setEditorType() is not working, the grid edits the field as simple text.

      When I manually use listgridfield.setEditorType() in a listGridField it works.

      When using the editorType just in the datasource, is there anything else I have to do with the ListGrid so it can automatically use the editorType set on the corresponding datasourcefield?

      Thanks,
      Cerávolo

      Comment


        #4
        Also, I have another issues.

        My custom editor is being proper shown inside the grid when I edit a row.

        The problem is that the value passed to my custom editor is the toString() of the object in the datasourcefield, but I need the entire object!

        Is it possible to pass the entire object of the field of the record being edited to my custom editor?

        The other issue is that I'm calling the setValue(String) of my custom editor (it inherits from a TextItem), but the text is not being written in the TextItem nor being sent to the grid cell after stop editing the row.

        Added:
        I think I know why the grid is not being updated when I call setValue() in my custom editor. Looking at SmartGwt source code, when the setEditorType() is called, the type of the FormItem and his properties are set to the ListGridField attributes directly by JS. The instance of the custom editor itself is ignored, so when I do a setValue() in my class that inherits from ItemText I'm setting a TextItem that is not the TextItem shown in the grid.
        Last edited by ceravolo; 24 May 2009, 18:11.

        Comment


          #5
          Use setEditValue() and related APIs to affect the values being managed by editors in the grid.

          If you still think DataSourceField.setEditorType() isn't working (it sounds like you figured out that problem?) please post a standalone test case.

          Comment


            #6
            Thanks @Isomorphic!

            Using the setEditValue() and some handlers implementation I could manage the editing grid value as you indicated.

            Best regards,
            Cerávolo

            Comment

            Working...
            X