Subject Re: How to make a record conditional uneditable in a Grid
From Milind Nighojkar <milinigh@yahoo.com>
Date Wed, 04 Aug 2021 22:35:18 -0400
Newsgroups dbase.getting-started

Hi Gaetano ,

Thanks it worked..

However I observed one thing for dropdown or for the date fields having datepicker it does not work meaning still we can edit the fields....

Any pointers?

Regards

Milind Nighojkar

> On 4/08/2021 04:57, Milind Nighojkar wrote:
> > Scenerio :
> > In a Grid I want to conditionally make record uneitable based on  value of a field in that record  say field  'status' having value 'Completed'
> > Any suggestions?
> >
> > Milind Nighojkar
>
> Hi Milind,
>
> When the rowset's autoedit property is set to true and you start editing
> a field in a grid, the beginEdit() event is automatically fired and so
> is the canEdit() event after that. Try to add the check for your
> conditions in the canEdit event and return false or true as needed with
> an IF/ENDIF block
>
> function query1_canEdit
>
> local bEdit
>
> bEdit=true
>
> if form.rowset.fields["status"].value.tolowercase()<>completed"
>
>      bEdit=false
>
>      msgbox("Cannot edit this fields as the status is not completed")
>
> endif
>
> return bEdit
>
> --
> Gaetano.
>