Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics SL (Archived)

Refresh Grid - Reload data from database

Posted on by Microsoft Employee

I have a custom form with a SAFGrid control. How do I force the grid to refresh in code so that it reloads the data from the database? Call DetailLoad(Spread1) does not work. Neither does Edit_Save / Edit_Cancel. Thanks in advance. (Solomon SL 7)

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Refresh Grid - Reload data from database

    Best and easy way is... GroupBox.Refresh (where GroupBox is the frame containing DSLGrid

  • Suggested answer
    Apps Mexico Profile Picture
    Apps Mexico 1,090 on at
    RE: Refresh Grid - Reload data from database

    Sorry I wrote the last post in a wrong place.

    But this is for you, on the Level property of the Update1 control you use "D" or "DA". The condition to the DetailLoad works is that the Level Property are set to DA. Example DetailTable;DA

  • Suggested answer
    Apps Mexico Profile Picture
    Apps Mexico 1,090 on at
    RE: Refresh Grid - Reload data from database

    Hi,


    If you don't have avalible user fields or you don't want to use them, one solution is adding a new custom table and do a customization to do the insert, update and read functions, this table is one to one relatioship with the inventory table. If you are interested i can develop this customization with all the fields that you need.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Refresh Grid - Reload data from database

    I do not think that is going to work for your case in that the header portion of the screen must have a SAFMaskedText field that serves as the filter to the grid control through the DBNAV setting of the Spread1 object.  While you have not specifically defined what your grid contains, I suspect it is the entire contents of a particular table and, therefore, would not be filtered.

    As I said earlier, I have several screens built that contain only a grid (to display the contents of various master tables) but I have not worried about refreshing the screen with newly added/deleted underlying data.  What I will do is see if I can make one of my screens do what you want and let you know.  If you figure it out before me, just let us know.

    Also, perhaps another forum member knows how to do this and can chime in.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Refresh Grid - Reload data from database

    SetLevelChg() doesn't work.

    What about if I hook it up to a header record? Say a textbox or combobox. How would I wire that up so that changes in the textbox/combobox trigger a grid refresh?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Refresh Grid - Reload data from database

    As you probably know, or are learning, SL forms do have limitations when working with the SDK.  While I have some screens that are a grid only screen, I have not addressed you particular situation so I do not know if the following would work or not.

    What you might try, is to have the refresh button execute a SetLevelChg to a value of 2 (updated) and then execute the detailload action.  Setting the level change status to 2 should simulate the same situation as if you had changed something in the grid.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Refresh Grid - Reload data from database

    Thanks Rick. I don't have a header record. There is only one grid (Levels D) on the form. I want the grid to refresh when the user clicks the "refresh" button on the form, not dynamically "sensing" changes by other users to the underlying table. Thanks.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Refresh Grid - Reload data from database

    To the best of my knowledge, SL does not have a way to automatically refresh a screen when the underlying data is changed by another user.  However, you could use the refresh button you mentioned to do that.  The grid is linked to the header of the screen.  So, if the refresh button moved you off of the current header record and then back on to it, the grid would refresh with the most current data in the database.  If you add logic to the refresh button to do a move next and then move prior on the header record, you would get the effect you want.  Be aware that your logic for the move next will have to deal with the situation where you are currently on the last record of the record set.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Refresh Grid - Reload data from database

    Thanks for replying. I have placed a "refresh" button on the form so the user can refresh the grid when the table data changes from other users or otherwise.

    I've been trying different things and noticed that only after I modify a value in the grid (no save required) the grid will refresh with a call to DetailLoad(Spread1). But this isn't a workaround I can use.

    Hopefully someone has a solution for me. Thanks.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Refresh Grid - Reload data from database

    Please clarify whether you are asking for the grid to reload when you change its linked value in the main form section or if you are asking that it refreshes when another user changes data going to the grid while you have the grid open.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans