(DataGrid) is there a message when the user has edited a cell ?

Andre.Bisseret Andre.Bisseret at inria.fr
Sat Jul 10 04:52:12 EDT 2010


Bonjour TheSlug,

Great help and learning for me!

I just played with your demo stack! Magnifique ;-))

Thank you very much for your time and for sharing your high knowledge  
about data grid! very much appreciated.
Seems you are the best as for Data Grid (after Trevor ;-O)))

I am a bit pigheaded so I tried your solution 1 in a data grid without  
template stack (in a new stack, a copy of group "DataGrid" of group  
"Templates" of stack "revDataGridLibrary").
I put the 3 handlers: "getprop uSumOfColumn[pColumn]", "on doSum" and  
"on CloseFieldEditor pFieldEditor" into the script of the data grid.

And all is working nicely :-)
So, seems I still can keep my current data grids in the app. I am  
making.

Thanks again and have a nice week-end

André


Le 9 juil. 10 à 21:29, zryip theSlug a écrit :

> You forget nothing André, but I have forget something in my previous  
> script!
> ;)
> In fact the new value edited in a cell will be updated in the data  
> of the
> column after the execution of the closeFieldEditor.
> So when we execute the sum, the uSumOfColumn will take the old value  
> of the
> cell, not the update value.
AH! OK
> For doing the task I propose two solutions :
> 1) Doing the sum outside the closeFieldEditor
> In the script of the DataGrid, add this handler
>
> on doSum
> set the text of fld "fldTotSum1_1" to the uSumOfColumn["Sum
> 1"] of the dgControl of me
> set the text of fld "fldTotSum2_1" to the uSumOfColumn["Sum
> 2"] of the dgControl of me
> end doSum
>
> In the behavior of the two columns update the closeFieldEditor like  
> this:
>
> on CloseFieldEditor pFieldEditor
>  send "doSum" to the dgControl of me in 0 secs
> end CloseFieldEditor
>
> Note we have to send the "doSum" event with a delay to execute the  
> sum in
> time ;).
>
> 2) For doing the sum inside the CloseFieldEditor we have to store  
> the value
> of the column in the data of the column ourself.
>
> For doing that, update the closeFieldEditor like this:
>
> on CloseFieldEditor pFieldEditor
> ## This part of the script store the new value of the cell in the data
>     put the dgIndex of me into theIndex
>     put the dgDataOfIndex[theIndex] of the dgControl of me into  
> theDataA
>     put the text of pFieldEditor into theDataA[the dgColumn of me]
>     set the dgDataOfIndex[theIndex] of the dgControl of me to theDataA
> ## This part of the script update the sums
>     set the text of fld "fldTotSum1_2" to the uSumOfColumn["Sum
> 1"] of the dgControl of me
>     set the text of fld "fldTotSum2_2" to the uSumOfColumn["Sum
> 2"] of the dgControl of me
> end CloseFieldEditor
>
> To answer a question I missed from you, the pFieldEditor contains a
> reference to the cell in edition in the grid. Its like a field if you
> prefer, and you can read the current value in it. It could be only a  
> cell in
> edition in a Grid.
>
>
> To simplify the experiment, I create a small demo stack. Be free to  
> play
> with it and use the scripts for your own needs ;)
> You can download the sum stack by following this link:
>
> exp 012_sum_in_dg.rev.zip<http://www.aslugontheroad.co.cc/index.php?option=com_phocadownload&view=category&download=5:experiment-012-doing-sum-in-a-data-grid&id=1:developers-tricks&Itemid=63 
> >
>
>
> Regards,
>
> -- 
> -Zryip TheSlug- wish you the best! 8)
> http://www.aslugontheroad.co.cc
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution






More information about the use-livecode mailing list