DatasetController Question
 
Forums / SmartComponent Library - Developer Forum / DatasetController Question

DatasetController Question

14 posts, 1 answered
  1. Roger Blanchard
    Roger Blanchard avatar
    400 posts
    Registered:
    29 Jun 2018
    18 Jun
    Link to this post
    I have a GUI for .NET form with a DatasetController type assigned to the BusinessEntityAdapter.

    We have a tool that will allow many fields in the record buffer to be assigned from a template table. I have added a method to the DatasetController to do this and it works just fine. However, how would I get the values assigned to the record buffer into the SmartViewer? 
  2. Roger Blanchard
    Roger Blanchard avatar
    400 posts
    Registered:
    29 Jun 2018
    18 Jun in reply to Roger Blanchard
    Link to this post
    Just a follow up. The user clicks the Update button on the toolbar and then will click a button on the viewer to assign the values from the template table. It would be easier to do this in the DatasetController as we can use buffer-copy.

    If this is not possible, we will just assign each individual UI control to the template value. 

    TIA.
  3. Mike Fechner
    Mike Fechner avatar
    331 posts
    Registered:
    14 Sep 2016
    18 Jun in reply to Roger Blanchard
    Link to this post
    There is no separate buffer. The DatasetController's default buffer for the temp-table is the buffer that's used for DataBinding.

    So to display the updates in the Viewer, call the BindingSource's Refresh() method (no row index). 

    https://docs.progress.com/de-DE/bundle/abl-reference/page/Refresh-method-Progress.Data.BindingSource.html#Refresh-method-Progress.Data.BindingSource
  4. Roger Blanchard
    Roger Blanchard avatar
    400 posts
    Registered:
    29 Jun 2018
    18 Jun in reply to Mike Fechner
    Link to this post
    Thanks Mike!!
  5. Roger Blanchard
    Roger Blanchard avatar
    400 posts
    Registered:
    29 Jun 2018
    18 Jun in reply to Mike Fechner
    Link to this post
    So that is working as you said. However, the "Save" tool is not enabled...how do I get the viewer to think a value has been changed so the toolbar is updated accordingly. 
  6. Mike Fechner
    Mike Fechner avatar
    331 posts
    Registered:
    14 Sep 2016
    18 Jun in reply to Roger Blanchard
    Link to this post
    By calling the viewer's SetModifyingState() method.
  7. Roger Blanchard
    Roger Blanchard avatar
    400 posts
    Registered:
    29 Jun 2018
    18 Jun in reply to Mike Fechner
    Link to this post
    I did that and the grid becomes disabled like when you are updating a record but the save tool is disabled until I manually make a change to a control on the viewer.
  8. Mike Fechner
    Mike Fechner avatar
    331 posts
    Registered:
    14 Sep 2016
    18 Jun in reply to Roger Blanchard
    Link to this post
    That sounds weird!

    What's the value of the SmartTableIOState property of the viewer after that? Maybe after an PROCESS EVENTS.?
  9. Roger Blanchard
    Roger Blanchard avatar
    400 posts
    Registered:
    29 Jun 2018
    18 Jun in reply to Mike Fechner
    Link to this post
    The value is ModifyingData. I have tried adding PROCESS EVENTS but same result.
  10. Roger Blanchard
    Roger Blanchard avatar
    400 posts
    Registered:
    29 Jun 2018
    18 Jun in reply to Roger Blanchard
    Link to this post
    This viewer has a GroupAssignSource so I probably have to call into that to call SetModifyingState
  11. Mike Fechner
    Mike Fechner avatar
    331 posts
    Registered:
    14 Sep 2016
    Answered
    18 Jun in reply to Roger Blanchard
    Link to this post
    That would be a reasonable idea. If that's the case, I do sense an improvement on the horizon though.
  12. Roger Blanchard
    Roger Blanchard avatar
    400 posts
    Registered:
    29 Jun 2018
    18 Jun in reply to Mike Fechner
    Link to this post
    That solved the issue. I have to call SetModifyingState in the Viewer:GroupAssignSource. 

    Thanks Mike!!
  13. Mike Fechner
    Mike Fechner avatar
    331 posts
    Registered:
    14 Sep 2016
    18 Jun in reply to Roger Blanchard
    Link to this post
    Changing the SmartViewerControls SetModifyingState like this seems to resolve this issue:

        /**
         * Purpose: Sets the TableIOState to ModifyingData
         * Notes:   Useful when modifying Viewer values through custom event handlers
         */
        METHOD PUBLIC VOID SetModifyingState():
            IF VALID-OBJECT (THIS-OBJECT:SmartGroupAssignSource) AND TYPE-OF (THIS-OBJECT:SmartGroupAssignSource, SmartViewerControl) THEN DO:
                CAST (THIS-OBJECT:SmartGroupAssignSource, SmartViewerControl):SetModifyingState() .
                RETURN .
            END.
            IF THIS-OBJECT:SmartTableIOState = TableIOStateEnum:FieldsEnabled THEN DO:
                THIS-OBJECT:SmartTableIOState = TableIOStateEnum:ModifyingData .
                /* Tell the SmartDataSource that the user has started to update data. */
                IF VALID-OBJECT(THIS-OBJECT:SmartDataSource) THEN
                    THIS-OBJECT:SmartDataSource:BeginUpdateState (THIS-OBJECT).
            END.
        END METHOD.
  14. Mike Fechner
    Mike Fechner avatar
    331 posts
    Registered:
    14 Sep 2016
    18 Jun in reply to Mike Fechner
    Link to this post
    SCL-4507
14 posts, 1 answered