Datagrid Table - Allow editing a field only when an other field contains data

zryip theSlug zryip.theslug at gmail.com
Sat Feb 9 10:49:32 EST 2019


Matthias,

A possible solution is to add an EditFieldText handler inside the datagrid
group script.

*command* EditFieldText pTheFieldEditor, pTheIndex, pTheCol
*end* EditFieldText

This message is invoked by the datagrid table prior to create the field
editor allowing to edit the cell.
Three parameters are passed :
- the field editor reference: pTheFieldEditor
- the index of the row: pTheIndex
- the key (the column name): pTheCol

The trick consist to test the name of the column the user is trying to edit
(for example col3 of the datagrid) :

*if* (pTheCol is "Col3") *then*


and then  get the content of the cell of another column by using the
GetDataOfIndex
function:

*put* GetDataOfIndex(pTheIndex, "Col2") into tTheValueToTest


If you want to allow the edition of the cell, then give a chance to the
EditFieldText  to reach the datagrid library

pass EditFieldText

if not, then simply not send it

And don't forget to pass the command for others columns of the datagrid.


Here is a final handler applying the recipe for a "col3" based of the
content of "col2". If the cell contains "yes" in col2 then the user is
allowed to edit the content of the cell in col3, if not the cell remains
locked. You can change "yes" for any value or change the test for checking
if the cel in "col2"l is empty or not


*command* EditFieldText pTheFieldEditor, pTheIndex, pTheCol
  *if* (pTheCol is "Col3")
*then**     put* GetDataOfIndex(pTheIndex, "Col2") into tTheValueToTest
     *if* (tTheValueToTest is "yes")
*then**        pass* EditFieldText
     *end*
*if*
*  else**   pass* EditFieldText
  *end*
*if**end* EditFieldText

On Fri, Feb 8, 2019 at 10:22 PM Bob Sneidar via use-livecode <
use-livecode at lists.runrev.com> wrote:

> Check the datagrid library.
> http://lessons.livecode.com/m/datagrid/l/7344-data-grid-api
>
> I believe there is a message sent when a field is opened for editing.
>
> Bob S
>
>
>
> > On Feb 8, 2019, at 11:51 , Matthias Rebbe via use-livecode <
> use-livecode at lists.runrev.com> wrote:
> >
> > Hi,
> >
> > in a project i need the  possibility to allow editing a datagrid table
> field only if an other field in the same row contains a value.
> > Is this possible? Any suggestions?
> >
> > Regards,
> >
> > Matthias
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


-- 
Zryip TheSlug
http://www.aslugontheroad.com



More information about the use-livecode mailing list