Announcement

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

    SelectItem backed by a DataSource question

    SmartClient Version: v9.1p_2014-03-20/PowerEdition Deployment (built 2014-03-20)
    GWT 2.5.1
    IE-11

    I have a SelectItem that is backed by a DataSource and provides and initial set of data to populate the drop down select list. One of the default items is meant to be editable by the user. After the initial set of data is loaded, if the user selects the custom item to be edited, an edit window will popup to gather the custom data.

    I'm having trouble getting the SelectItem to display the updated values for the selected ListGridRecord. Here is what I am doing in the ClickHandler for the custom window to change the value of the selected item in the SelectItem:

    Code:
    String caption = "Custom Dates (" + customStartDate + " - " + customEndDate + ")";
                    ListGridRecord record = selectItem.getSelectedRecord();
                    record.setAttribute("Caption", caption);
                    record.setAttribute("MinDate", customStartDate);
                    record.setAttribute("MaxDate", customEndDate);
                    selectItem.redraw();
                    timeFrameForm.markForRedraw();
    The display does not change to reflect the change in the ListGridRecord? How can I get the SelectItem to update the display with the new Caption on the selected ListGridRecord?

    When I click to open the SelectItem to see all values, I see the changed ListGridRecord with the new caption. But only when I click to open the SelectItem.

    I need the display to change after I modify the ListGridRecord in the code above, because the SelectItem has already been selected to the custom value for the user to change. So I need the SelectItem to update the display. The selectItem.redraw() and the containing form's timeFrameForm.markForRedraw() has no affect after the ListGridRecord has been modified.
    Last edited by JLivermore; 15 Apr 2014, 07:19. Reason: more details

    #2
    Same types of issues

    I am having the same types of issues.

    Comment


      #3
      If we understand you correctly:
      - you have a SelectItem backed by an OptionDataSource, with a valueField and a displayField (let's call that the "ID" and the "title").
      - the user selects a value (so they will see the title of the selected item)
      - you then want the underlying record to have it's title modified via some other piece of UI, and the select to display the new title, automatically.

      This can be achieved by standard databinding behavior - simply update the record in the dataSource either via an explicit call to DataSource.updateData(), or if you're working with a standard DataBound component to do the editing, via a standard save.
      The SelectItem will automatically refresh to display the new title for the record (and if the user shows the pick list, the new title will show up in the pick list as well)

      Regards
      Isomorphic Software

      Comment


        #4
        yes, so far so good. however, this user edit does not need to go back to the server, it's state is transitive for the user's session only and no need to persist.

        when I tried

        Code:
        String caption = "Custom Dates (" + customStartDate + " - " + customEndDate + ")";
                        ListGridRecord record = selectItem.getSelectedRecord();
                        record.setAttribute("Caption", caption);
                        record.setAttribute("MinDate", customStartDate);
                        record.setAttribute("MaxDate", customEndDate);
        
                        DataSource dataSource = selectItem.getOptionDataSource();
                        dataSource.updateData(record);
        i get a pop-up saying 'Operation type 'update' is not supported by this DataSource'

        and here is my datasource
        Code:
        <?xml version="1.0" encoding="UTF-8"?>
        <DataSource
            ID="post_trade_time_frame"
            serverType="generic">
            <fields>
                <field name="id"      type="integer" hidden="true"       primaryKey="true"/>
                <field name="name"    type="text" title="Description"/>
                <field name="startPoint"    type="Date" title="Start Point"/>
                <field name="endPoint"    type="Date" title="End Point"/>
            </fields>
        
            <operationBindings>
                <binding operationType="fetch" serverMethod="fetchTimeFrame">
                    <serverObject lookupStyle="spring" bean="postTradeService"/>
                </binding>
            </operationBindings>
        
        </DataSource>
        is it a matter of creating an 'update' stub for the datasource that will service the 'update' call but simply do nothing?

        Comment


          #5
          that worked.

          Comment


            #6
            Yes - that would basically work, however if you instantiate a new fetch against the DataSource (or invalidate cache or similar), you would end up seeing the old value if haven't persisted it in any way, since your server side fetch logic wouldn't be aware of the edit presumably.

            If this is a concern, your "update" implementation could of course store the new value in memory, and your fetch method could pick this up, so as far as this user-session is concerned the server-value is the user-edited value (even if it wasn't persisted to permanent storage).

            Comment

            Working...
            X