This is a migrated thread and some comments may be shown as answers.

HtmlTextBox and spaces

5 Answers 28 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
NiccoMlt
Top achievements
Rank 1
Veteran
NiccoMlt asked on 30 Mar 2021, 01:36 PM

Hi,

how should I transform data from my DataSource to show spaces correctly in HtmlTextBox?

The HTML renderer ignores repeated spaces (as I expeceted), so I thought about replacing space character " " with the non-breaking space HTML entity " ".

It is actually feasible with HtmlTextBoxes with a constant content, but the space collapse is also applied on strings from DataSource, and this behavior is not acceptable, as those spaces are meaningful.

Is there a way to transform values from DataSource? I tried to wrap Fields references with the Replace() expression, trying to replace spaces with related HTML entity, but it does not work.

I paste a TRDX with embedded JSON data source down here:

<?xml version="1.0" encoding="utf-8"?>
<Report DataSourceName="jsonDataSource1" Width="17cm" Name="Try not to collapse spaces" SnapGridSize="0.1cm" xmlns="http://schemas.telerik.com/reporting/2021/1.0">
  <DataSources>
    <JsonDataSource Name="jsonDataSource1">
      <Source>
        <String>ew0KICAiZm9vIjogInRoZSBzcGFjZXMgIGluc2lkZSAgIHRoaXMgICAgc3RyaW5nICAgICBzaG91bGQgbm90IGJlIGNvbGxhcHNlZCINCn0=</String>
      </Source>
    </JsonDataSource>
  </DataSources>
  <Items>
    <DetailSection Height="7cm" Name="detailSection1">
      <Items>
        <HtmlTextBox Width="16cm" Height="1cm" Left="0.5cm" Top="1.7cm" Value="HTMLTextBox with Field: {Fields.foo}" Name="htmlTextBox1" />
        <HtmlTextBox Width="16cm" Height="1cm" Left="0.5cm" Top="6cm" Value="These&nbsp;spaces&nbsp;&nbsp;should&nbsp;&nbsp;&nbsp;not&nbsp;&nbsp;&nbsp;&nbsp;be dropped" Name="htmlTextBox2" />
        <HtmlTextBox Width="16cm" Height="1cm" Left="0.5cm" Top="3.4cm" Value="HTMLTextBox with Field: {Replace(Fields.foo, " ", " ")}" Name="htmlTextBox3" />
        <HtmlTextBox Width="16cm" Height="1cm" Left="0.5cm" Top="4.6cm" Value="HTMLTextBox with Field: {HtmlEncode(Fields.foo)}" Name="htmlTextBox4" />
        <TextBox Width="16cm" Height="0.9cm" Left="0.5cm" Top="0.3cm" Value="Standard TextBox with Field: {Fields.foo}" Name="textBox1" />
      </Items>
    </DetailSection>
  </Items>
  <PageSettings PaperKind="A4" Landscape="False">
    <Margins>
      <MarginsU Left="2cm" Right="2cm" Top="2cm" Bottom="2cm" />
    </Margins>
  </PageSettings>
  <StyleSheet>
    <StyleRule>
      <Style>
        <Padding Left="2pt" Right="2pt" />
      </Style>
      <Selectors>
        <TypeSelector Type="TextItemBase" />
        <TypeSelector Type="HtmlTextBox" />
      </Selectors>
    </StyleRule>
  </StyleSheet>
</Report>

 

What do you think I'm doing wrong?

5 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 02 Apr 2021, 12:57 PM

Hi NiccoMlt,

I confirm the observed behavior. Note that to overcome it, you may use the following Expression in 'Html view' of the HtmlTextBox editor:

=Replace(Fields.foo, " ", "&nbsp;")

Here is a link to a silent video demonstrating the this worked locally.

Regards,
Todor
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
NiccoMlt
Top achievements
Rank 1
Veteran
answered on 02 Apr 2021, 03:25 PM

Hi Todor,

thank you for your answer, but it doesn't solve my problem.

Your solution only works if the content of the HtmlTextBox is the aformentioned expression. If the expression is embedded inside some text it doesn't work.

Try for example setting as value:

Hello, {Replace(Fields.foo, " ", "&nbsp;")}

0
Accepted
Todor
Telerik team
answered on 07 Apr 2021, 10:13 AM

Hello NiccoMlt,

You are right that the approach doesn't work with embedded expressions. You may transform any embedded expression into a regular one. For example:

="Hello, " + Replace(Fields.foo, " ", "&nbsp;")

Regards,
Todor
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
NiccoMlt
Top achievements
Rank 1
Veteran
answered on 07 Apr 2021, 02:37 PM

Oh I understand, thank you.

Do you think this limitation is here to stay or are there any plans to change this behavior in a future version of Telerik Reporting?

I'm implementing an automatic converter from an old technology to Telerik and your solution complicates the implementation noticeably...

0
Todor
Telerik team
answered on 12 Apr 2021, 10:05 AM

Hi NiccoMlt,

I'm afraid it is not in our immediate plans to fix the observed behavior. You may log it in our public feedback portal so that other users to be able to vote and increase its priority.

Regards,
Todor
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
General Discussions
Asked by
NiccoMlt
Top achievements
Rank 1
Veteran
Answers by
Todor
Telerik team
NiccoMlt
Top achievements
Rank 1
Veteran
Share this question
or