Page 1 of 1

copy format of text to datagrid

Posted: Fri Apr 28, 2017 10:48 pm
by jalz
Hi Guys,

I have a field I type text into. I can style, change text size and align it in the standard ways. Once I stop editing the field I press a button which then copies the text from that particular field into the equivalent field in my datagrid (form). The issue I have is when I copy the text from that field to the datagrid I lose all the formatting, thought the only way to do this was using htmltext as the option.

I use the following code,

the button I press to copy the text

Code: Select all

on mouseup
set the text of field "fld_line_description" of me to pDataArray["label 3"]
dispatch "AddData" to group "dg_data" with theDataA, tLineNo
end mouseup

datagrid form code which fills the field

Code: Select all

on FillInData pDataArray
set the htmltext of field "fld_line_description" of me to pDataArray["label 3"]
end FillInData


Re: copy format of text to datagrid

Posted: Fri Apr 28, 2017 11:27 pm
by Klaus
Hi Jalz,
jalz wrote:...
the button I press to copy the text

Code: Select all

on mouseup
  set the text of field "fld_line_description" of me to pDataArray["label 3"]
  dispatch "AddData" to group "dg_data" with theDataA, tLineNo
end mouseup
not sure I get it, but this script does not copy anything!?

Maybe you mean:

Code: Select all

on mouseup
  put the htmltext of field "fld_line_description" of me into pDataArray["label 3"]
  dispatch "AddData" to group "dg_data" with theDataA, tLineNo
end mouseup
?

And is tLineNo declared as local or globa?


Best

Klaus

Re: copy format of text to datagrid

Posted: Fri Apr 28, 2017 11:53 pm
by jalz
Hi Klaus

Thanks for replying. Trying to get my head stuck back into LIvecode :).

Yes you are absolutely right, it is htmltext I am using when I am storing it in a variable.

The datagrid fills in the data using the FillInData command.

set the text of field "fld_line_description" of me to pDataArray["label 3"]

I've been playing with the code, I've now got the datagrid field to display html tags (which includes the formatting). How do I get the field to display in 'normal' text?

Thanks
Jalz

Re: copy format of text to datagrid

Posted: Sat Apr 29, 2017 12:04 pm
by Klaus
Hi jalz,
jalz wrote:I've been playing with the code, I've now got the datagrid field to display html tags (which includes the formatting). How do I get the field to display in 'normal' text?
in that case just copy the text of your field:

Code: Select all

...
put the text of field "fld_line_description" of me into pDataArray["label 3"]
...
If you need an "ad hoc" conversion from HTMLTEXT to "normal" text I would use a little function like this:

Code: Select all

...
set the text of field "fld_line_description" of me to htmltext2text (pDataArray["label 3"])
...

function htmltext2text tHTMLTEXT
   set the htmltext of the templatefield to tHTMLTEXT
   put the text of the templatefield into tText
   reset the templatefield
   return tText
end htmltext2text
Tested and works! :D

Best

Klaus

Re: copy format of text to datagrid

Posted: Sat Apr 29, 2017 7:03 pm
by jalz
Thanks Klaus

That worked :D

Re: copy format of text to datagrid

Posted: Mon May 01, 2017 4:59 pm
by Klaus
jalz wrote:Thanks Klaus

That worked :D
Did you really doubt? 8)