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

zryip theSlug zryip.theslug at gmail.com
Sat Jul 10 05:45:30 EDT 2010


2010/7/10 Andre.Bisseret <Andre.Bisseret at inria.fr>

> Bonjour TheSlug,
>

Bonjour André ;)


>
> 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.
>

You're welcome, my pleasure 8-)


> Seems you are the best as for Data Grid (after Trevor ;-O)))
>

Hum, a too red slug will be an easiest target for shovels, so I can't accept
the compliment. But thank you ;)
Trevor is definitively the man here. Preferable to say that I have read a
lot of his lessons and I have now a good understanding how Data Grid working
;)


>
> 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.
>

Great!


>
> Thanks again and have a nice week-end
>

Have a nice week-end too! 8-)


>
> 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
>> >
>
>


-- 
-Zryip TheSlug- wish you the best! 8)
http://www.aslugontheroad.co.cc



More information about the use-livecode mailing list