Page 1 of 1

Dataset.Post clears formatting/unicode from TDBRichViewEdit

Posted: Fri Oct 24, 2014 6:29 pm
by stuartclennett
Hi,

(Please bear with me, I am new to the TRichView components)

I have a blob field in a SQL Server database that I've hooked up a TDBRichViewEdit component (via FireDAC & RemObjects DataAbstract)

If I paste in unicode characters they're showing fine until I call dataset.post (via a Save button) and then the unicode characters change to ????

If I make any formatting changes (bold, Heading style) etc, they are all lost when Post is called.

There are no beforePost/afterPost events on the dataset.

I've replaced the TDBRichViewEdit component with another one straight off the component palette (i.e. to ensure that I haven't switched any properties), and it still does the same thing.

The formatting functions (styles, font name and font size) are all lifted straight from your REditor demo.

Note, this _was_ working earlier, but I don't know what I've done wrong?

Do you have any suggestions please?

Thanks,
Stuart

Delphi XE6
RichView 15.1.2

Posted: Sat Oct 25, 2014 7:04 am
by Sergey Tkachenko
If you right click the editor in Delphi, choose Options, what do you see:
- allow adding styles dynamically
- use a predefined set of styles?

(this option may be applied to new editors placed on a form, if you checked "default" when applied it last time)

Posted: Mon Oct 27, 2014 10:00 am
by stuartclennett
Thanks for your reply Sergey.

Right click on component > Settings...

I have "Allow adding styles dynamically" ticked.

Here's a screen grab of all three settings pages:

http://imgur.com/4wUzcrg


Thanks
Stuart

Posted: Mon Oct 27, 2014 10:54 am
by Sergey Tkachenko
Is this DBRichViewEdit linked to its own TRVStyle, or may be itshares TRVStyle with another TRichView?

Posted: Mon Oct 27, 2014 11:48 am
by stuartclennett
Hi,

No it has it's own RVStyle component.

I just put together a test app (connected to the same DB server) and the TDBRichViewEdit behaves as expected.

So I copied and pasted the RVStyle & DBRichViewEdit components from the test app to the 'real' app, and the problem still persists.

I am really stuck with this, don't know what I am doing in the 'real' application to make it behave like this. :(

I have made a short gif to show what happens in my app:

http://imgur.com/mxnTYev


Thanks for your continued assistance,

Stuart

Posted: Mon Oct 27, 2014 3:50 pm
by stuartclennett
I think this might be significant:

I wanted to see the 'raw' contents of the field behind the TDBRichViewEdit, so I added a TDBMemo component on the same form.

The TDBMemo shows the text from the DBRichViewEdit, but (obviously) in plain text, even though rvfoSaveBinary is flagged on the DBRichViewEdit control and fieldformat = rvdbRVF.

The underlying field is a blob field - SQL Server type "varbinary(max)".

Does this help ?

Thanks
Stuart

Posted: Mon Oct 27, 2014 5:24 pm
by stuartclennett
Here's another gif that shows the DBRichViewEdit and a DBMemo attached to the same field.

At the start, the contents are obviously binary (edited in my test app)

When I edit the DBRichViewEdit nothing happens until I try to bold some text - then the RAW field contents change to plain text.

Then hitting Save (i.e. Dataset.Post) converts the DBRichViewEdit to plain text as well.

http://i.imgur.com/9tPYLDe.gif

Thanks
Stuart

Posted: Tue Oct 28, 2014 1:19 pm
by Sergey Tkachenko
According to your first screenshot, field saving format is RTF, not RVF.
But it's strange that you can see a plain text.

May be you have OnSaveCustomFormat event processed?

Posted: Tue Oct 28, 2014 3:21 pm
by stuartclennett
Hi Sergey,

I didn't have OnSaveCustomFormat event assigned.

However, your comment got me to question the FieldFormat property and I then found that my code was setting the FieldFormat to 'Text' during the formcreate event. (the record in the database can be either rich text or plain text and my IF statement was wrong.

Phew.

Many many thanks for your help -- great support & I apologise for making such a newbie mistake.

Stuart