| Subject |
Re: Field validation in grid |
| From |
Ken Mayer <dbase@nospam.goldenstag.net> |
| Date |
Mon, 9 Aug 2021 12:23:47 -0700 |
| Newsgroups |
dbase.getting-started |
On 8/9/2021 11:08 AM, Milind Nighojkar wrote:
> Scenerio:
> I am in grid.
> I want to validate a field say a date field D1. Validation is D1 > date() with error message when cursor is leaving field or record.
> I want cursor to stay in filed till feild value satisifies the validation condition
>
> Code is something like this
> function editorControl_onLostFocus()
> local lRet
> lRet = false
> if this.value < date()
> lRet = false // Allow cancel
> this.validErrorMsg := "Past Date NOT allowed"
> else
> lRet = true
> endif
> return lret
>
>
> Any suggestion ?
>
> I used various ways usingevents like onlostfocus,valid for field
> At row level rowset_canEdit()
>
You cannot put focus directly on the specific row/column of a grid. This
is a missing ability from the editorControl for the grid, and I believe
it has been posted as a bug report several times.
I recommend not allowing editing in a grid. This is because it is much
harder to do things, such as what you're trying. Instead, provide a set
of controls above (below, to the side, whatever works for you) for the
current record, allow editing in those controls (datalinked to the
fields in the table), and when saved they changes will reflect in the
grid as well ... With the standard controls, you can allow the error
checking you're trying ... but not with the grid.
Ken
--
*Ken Mayer*
Ken's dBASE Page: http://www.goldenstag.net/dbase
The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm
dBASE Web Tutorial: http://www.goldenstag.net/dbase/WebTutorial/00_Menu.htm
|
|