MacToIso
Trevor DeVore
lists at mangomultimedia.com
Tue Dec 22 16:25:19 EST 2009
On Dec 22, 2009, at 3:54 PM, JosepM wrote:
> Yes. I fetching data using SQL Yoga and insert row manually to the
> datagrid,
> and after insert from the datagrid to the database with SQL Yoga, so
> if I
> understand well with
>
> on FillInData pData
> set the uUTF8Text of field "Name" of me to pData
> end FillInData
>
> Then encode to the datagrid is ok and don't worry for, isn't? But If
> I edit
> directly into the datagrid? I need do the same in the "closeEditor"?
Yes, you need to update the default behavior for opening and saving
text to the Data Grid field editor (I wish Rev worked with UTF8
natively).
When opening the field editor in your column behavior you are already
calling EditFieldText. The Data Grid is going to work with the 'text'
property of the fields by default. You can override this by setting
the dgTemplateFieldEditor["utf8text"] property (you can also pass in
"htmltext", "rtftext", or "unicodetext") before calling
dgTemplateFieldEditor. Setting the dgTemplateFieldEditor["utf8text"]
property of the Data Grid will use the value you assign rather than
the 'text' of the field.
I haven't fully documented dgTemplateFieldEditor but there is an
example in the lesson on aligning decimal columns. There really isn't
much to it:
<http://lessons.runrev.com/manuals/datagrid/lessons/7331>
When closing the field editor you will need to extract the UTF8 text
of the field editor. The example in the manual actually shows how to
do this. Search for UTF8 on this page:
How Do I Save Changes The User Makes In An Editor Field To An External
Data Source?: <http://lessons.runrev.com/spaces/lessons/manuals/datagrid/lessons/7337-How-Do-I-Save-Changes-The-User-Makes-In-An-Editor-Field-To-An-External-Data-Source-
>
> To fill the fields I read directly from the rows of the datagrid so
> the
> performance is better so I use a remote mysql.
>
> For this fields I have integrated your Placeholder Behavior that use
> some
> UTF actions. It's enough or I need to decode? I use the set uText
> of ... and
> put the uText of xxx into...
Just remember:
1) Encode from UTF8 to UTF16 when assigning content TO a field.
2) Encode from UTF16 to UTF8 when retrieving content FROM a field.
If you look at the uText definition for the Placeholder behavior it
works on the text property of the field. The behavior also has
uUTF8Text getProp/setProp handlers that you can use though.
<http://lessons.runrev.com/buckets/784/lessons/6501>
> To insert and update I move the data from these fields to the SQL Yoga
> record object. Here I must encode from the uText?
Just insert the uUTF8Text of the field into the Record object.
> To use this prop I suppose that I must create these prop for each
> field that
> not use Placeholder Behavior, isn't?
You don't need to create the props for any field. Just put the getProp/
setProp definitions in the message path. When you try to access the
uUTF8Text property of an object or set the uUTF8Text property of an
object the handlers will kick in. No custom property value is being
stored in the field itself.
> ======================
> CODE
> ======================
>
> setprop uUTF8Text pText
> set the unicodetext of the target to uniencode(pText, "UTF8")
> end uUTF8Text
>
>
> getprop uUTF8Text
> return _UTF16ToUTF8(the unicodetext of the target)
> end uUTF8Text
Oops, I forgot to include _UTF16ToUTF8.
private function _UTF16ToUTF8 pText
put unidecode(pText, "UTF8") into theText
replace NULL with empty in theText ## why? Because a NULL crept
in once
return theText
end _UTF16ToUTF8
--
Trevor DeVore
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
Releasable Revolution Resources for Developers: http://revolution.bluemangolearning.com
More information about the use-livecode
mailing list