Sorting datagrid column with a tricj?
bobsneidar at iotecdigital.com
Mon Nov 5 12:43:47 EST 2018
Actually I came up with a fairly elegant solution which is quite simple. In the column behavior script I added some code:
on FillInData pData
-- This message is sent when the Data Grid needs to populate
-- this template with the column data. pData is the value to be displayed.
set the text of the long ID of me to pData ## temp workaround for
-- Sly Labs! Custom Column Formatting
dispatch customFillInData to me with pData, the dgColumn of me
Of course, I had to edit the permissions of the folder containing the behavior script, as well as the script only stack itself so I could save the changes.
Next I added this to my datagrid:
on customFillInData pData, pColumn
put the text of the target into tColumnValue
if tColumnValue is not empty then \
set the text of the target to \
formatDate(word 1 of tColumnValue, "abbr date") && word 2 of tColumnValue
-- formatDate() is my own function which converts any date to one of several custom formats LC does not use
Not only does this work famously, but it does not affect the underlying data. It only updates the value in the datagrid field. This can be built upon to create datagrids which have a spreadsheet-like field formatting while the underlying data is the raw value. You could even store equasions and then resolve the equasions in the display, just like a spreadsheet.
I'll have to figure out how to reformat going the other direction, so that editing the displayed data will store the raw value and not the displayed value.
Anyone wanna chime in on this method before I submit a change request?
> On Nov 5, 2018, at 09:22 , Trevor DeVore via use-livecode <use-livecode at lists.runrev.com> wrote:
> On Mon, Nov 5, 2018 at 11:03 AM Bob Sneidar via use-livecode <
> use-livecode at lists.runrev.com> wrote:
>> Hi Trevor.
>> Just a heads up, I followed those instructions in the lesson to the
>> letter. It broke my datagrid. It would no longer populate and I could not
>> select a row by clicking on it.
>> It may have to do with the new dg behavior heirarchy. I could see that
>> someone else was having difficulty as late as last Friday, although it
>> looks like it's a different issue.
> I would suggest submitting a note on the article letting the team know. You
> are probably right about the new dg behavior changes breaking it. I know it
> used to work as that is how I always customized how columns display data
> when it was simply a matter of reformatting the text.
> Trevor DeVore
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the use-livecode