none
problems when refreshing grids. RRS feed

  • Question

  • The short story: Using a timer to issue any kind of refresh while the user edits something in a grid causes problems.

    The long story:

    As I mentioned in my previous post, I have a form with 3 grids. The grids represent the same table opened up AGAIN.

    grd1 has a column with a combo box.

    grd2 has a column with a textbox the user can just type in.

    The information in the table gets updated by several other devices, including wifi tablets, so all 3 grids mentioned need to show the updates while the user is using the form. I have a simple timer that issues thisform.grd1.refresh() and thisform.grd2.refresh() every 10 seconds.

    In grd1, if the user changes anything in the combo, and doesn't move the focus to another column, then when the refresh kicks in, the entry he selected disappears and part of the grid turns gray.

    In grd2, if the user changes the text box, then if the timer kicks in, a "record not locked" error pops out.

    These don't happen if instead of a timer, I use a button that does the refresh. So its probably something to do with refreshing anything while the user is editing.

    Also, the problem in grid1 happens even if I refresh only grid2 - so if the user selected an item in grid1, and timer kicks in to refresh grid2 - the combo in grid1 gets kinda corrupted with gray background.

    I guess I have to limit the timer to be triggered only when the user is not editing anything.

    Any further help would be appreciated.

    Thursday, January 10, 2019 4:26 AM

Answers

  • This depends on your how your form is implemented. Is the grid always writable? Do you have Edit/Save button on the form?

    When, Valid, GotFocus, LostFocus are events you could use. Enable Event tracking in Debugger and identify the even which is suitable for your needs.

    You could also use _screen.ActiveForm.ActiveControl. 

    • Marked as answer by Aleniko2 Friday, January 11, 2019 2:13 AM
    Thursday, January 10, 2019 6:38 PM
    Moderator
  • Take a look at my paper in BindEvents and Access and Assign methods: http://tomorrowssolutionsllc.com/ConferenceSessions/Bind%20Events%20for%20Better%20Applications.PDF.

    Basically, you want to set a form property as soon as the user starts editing and clear it when they stop.

    Tamar

    • Marked as answer by Aleniko2 Friday, January 11, 2019 2:13 AM
    Thursday, January 10, 2019 9:27 PM
    Moderator

All replies

  • Yes, to do the refresh when user is not editing is a good and reliable way. Everything else can bring problems you are describing. Combo in a grid means just additional contribution to the behavior uncertainty...

    What you could try is to remember the column and value and cursor position where user is editing, then change focus to the refreshed grid, refresh it and return the focus back into the original grid and position... This also means to suppress possible validations and maybe more.

    Thursday, January 10, 2019 4:59 PM
    Moderator
  • Pavel;

    Any ideas how to instead refresh when the user is NOT in editing?

    I can use mouse positions but I don't know if this is a good idea either.

    Another option is to have the editing fields set a property at valid.

    Any other ideas?

    Thanks!

    Thursday, January 10, 2019 5:47 PM
  • This depends on your how your form is implemented. Is the grid always writable? Do you have Edit/Save button on the form?

    When, Valid, GotFocus, LostFocus are events you could use. Enable Event tracking in Debugger and identify the even which is suitable for your needs.

    You could also use _screen.ActiveForm.ActiveControl. 

    • Marked as answer by Aleniko2 Friday, January 11, 2019 2:13 AM
    Thursday, January 10, 2019 6:38 PM
    Moderator
  • Take a look at my paper in BindEvents and Access and Assign methods: http://tomorrowssolutionsllc.com/ConferenceSessions/Bind%20Events%20for%20Better%20Applications.PDF.

    Basically, you want to set a form property as soon as the user starts editing and clear it when they stop.

    Tamar

    • Marked as answer by Aleniko2 Friday, January 11, 2019 2:13 AM
    Thursday, January 10, 2019 9:27 PM
    Moderator
  • Tamar;

    Thanks. I did just that on a column level, but bindevent would make it more generic. Helpful.

    Friday, January 11, 2019 2:12 AM