Skip to main content

Data for column is shown with tags

Comments

6 comments

  • VISUI

    If the data is stored with HTML tags, it is going to be returned from the stored procedure with HTML tags. 

    You can set the format for the label to HTML to render that label's contents as HTML


    <Report ID="LogiForum.htmlFormat">
      <Body>
        <DataTable ID="dt">
          <DataLayer Type="Static">
            <StaticDataRow Column1="Row 1" Column2="&lt;p&gt;&#xD;&#xA;This paragraph&#xD;&#xA;contains a lot of lines&#xD;&#xA;in the source code,&#xD;&#xA;but the browser&#xD;&#xA;ignores it.&#xD;&#xA;&lt;/p&gt;&#xD;&#xA;&#xD;&#xA;&lt;p&gt;&#xD;&#xA;This paragraph&#xD;&#xA;contains         a lot of spaces&#xD;&#xA;in the source         code,&#xD;&#xA;but the        browser&#xD;&#xA;ignores it.&#xD;&#xA;&lt;/p&gt;" />
            <StaticDataRow Column1="Row 2" Column2="&lt;h1&gt;This is heading 1&lt;/h1&gt;&#xD;&#xA;&lt;p&gt;This is some text.&lt;/p&gt;&#xD;&#xA;&lt;hr&gt;&#xD;&#xA;&lt;h2&gt;This is heading 2&lt;/h2&gt;&#xD;&#xA;&lt;p&gt;This is some other text.&lt;/p&gt;&#xD;&#xA;&lt;hr&gt;" />
          </DataLayer>
          <DataTableColumn ID="colColumn1" Header="Column1">
            <Label ID="lblColumn1" Caption="@Data.Column1~" />
            <DataColumnSort DataColumn="Column1" />
          </DataTableColumn>
          <DataTableColumn ID="colColumn2" Header="Column2">
            <Label ID="lblColumn2" Caption="@Data.Column2~" Format="HTML" />
            <DataColumnSort DataColumn="Column2" />
          </DataTableColumn>
        </DataTable>
      </Body>
    </Report>

     

     

    If you don't want to display the html formatting, you can use a user defined function inside sql to unwrap html tags.  This would probably be the best solution, but since you are dealing with a stored procedure, you may not have this ability.

    https://stackoverflow.com/questions/457701/how-to-strip-html-tags-from-a-string-in-sql-server

    You can use a JavaScript function within the formula for a calculated column which removes the tags as well.


    <Report ID="LogiForum.htmlFormat">
      <Body>
        <DataTable ID="dt">
          <DataLayer Type="Static">
            <StaticDataRow Column1="Row 1" Column2="&lt;p&gt;&#xD;&#xA;This paragraph&#xD;&#xA;contains a lot of lines&#xD;&#xA;in the source code,&#xD;&#xA;but the browser&#xD;&#xA;ignores it.&#xD;&#xA;&lt;/p&gt;&#xD;&#xA;&#xD;&#xA;&lt;p&gt;&#xD;&#xA;This paragraph&#xD;&#xA;contains         a lot of spaces&#xD;&#xA;in the source         code,&#xD;&#xA;but the        browser&#xD;&#xA;ignores it.&#xD;&#xA;&lt;/p&gt;" />
            <StaticDataRow Column1="Row 2" Column2="&lt;h1&gt;This is heading 1&lt;/h1&gt;&#xD;&#xA;&lt;p&gt;This is some text.&lt;/p&gt;&#xD;&#xA;&lt;hr&gt;&#xD;&#xA;&lt;h2&gt;This is heading 2&lt;/h2&gt;&#xD;&#xA;&lt;p&gt;This is some other text.&lt;/p&gt;&#xD;&#xA;&lt;hr&gt;" />
            <CalculatedColumn Formula="(&quot;@Data.Column2~&quot;).replace(/(&lt;([^&gt;]+)&gt;)/gi, &quot;&quot;)" ID="Column2" />
          </DataLayer>
          <DataTableColumn ID="colColumn1" Header="Column1">
            <Label ID="lblColumn1" Caption="@Data.Column1~" />
            <DataColumnSort DataColumn="Column1" />
          </DataTableColumn>
          <DataTableColumn ID="colColumn2" Header="Column2">
            <Label ID="lblColumn2" Caption="@Data.Column2~" />
            <DataColumnSort DataColumn="Column2" />
          </DataTableColumn>
        </DataTable>
      </Body>
      <ideTestParams />
    </Report>

     

    0
  • Seema Verma

    Hi VISUI , 

    This is working fine if we format the label to HTML . but when we refresh the data table it causes the below mentioned error .

    I just added a refresh element and that's required to add that element .

    And if we are using second approach by using Javascript its not completely removing the html tags and also its removing the tags without impacting the label i.e., <h1> hello</h> , here its removing this <h> but not increasing its font size .Please find a screenshot below.

    Thanks,

    Simran

     

    0
  • Seema Verma

    Hi VISUI ,

    One point also i would like to add , if we have image as  a value in the column , then image is not getting shown in the column if we set format of label as HTML  . Also when we are taking export , its keeps on loading the export page . I believe its because of we have image in the column . Please find a screenshot below for an reference .In this screenshot i removed HTML format from this column to show tags 

    Thanks,

    Simran

    0
  • VISUI

    If the image is not showing up within the browser, it is probably the link itself is posing issues for logi.  Possibly the SSL url?

    If the image is not showing up within the export, it could potentially be the same issue.  Try to keep image src local to the logi 

    The following worked for me:

    <Report ID="LogiForum.htmlFormat">
      <Body>
        <DataTable ID="dt">
          <DataLayer Type="Static">
            <StaticDataRow Column1="Row 1" Column2="&lt;p&gt;&#xD;&#xA;This paragraph&#xD;&#xA;contains a lot of lines&#xD;&#xA;in the source code,&#xD;&#xA;but the browser&#xD;&#xA;ignores it.&#xD;&#xA;&lt;/p&gt;&#xD;&#xA;&#xD;&#xA;&lt;p&gt;&#xD;&#xA;This paragraph&#xD;&#xA;contains         a lot of spaces&#xD;&#xA;in the source         code,&#xD;&#xA;but the        browser&#xD;&#xA;ignores it.&#xD;&#xA;&lt;/p&gt;" />
            <StaticDataRow Column1="Row 2" Column2="&lt;h1&gt;This is heading 1&lt;/h1&gt;&#xD;&#xA;&lt;p&gt;This is some text.&lt;/p&gt;&#xD;&#xA;&lt;hr&gt;&#xD;&#xA;&lt;h2&gt;This is heading 2&lt;/h2&gt;&#xD;&#xA;&lt;p&gt;This is some other text.&lt;/p&gt;&#xD;&#xA;&lt;hr&gt;" />
            <StaticDataRow Column1="Row 2" Column2="&lt;h1&gt;This is heading 1&lt;/h1&gt;&#xD;&#xA;&lt;p&gt;This is some text.&lt;/p&gt;&#xD;&#xA;&lt;hr&gt;&#xD;&#xA;&lt;h2&gt;This is heading 2&lt;/h2&gt;&#xD;&#xA;&lt;p&gt;This is some other text.&lt;/p&gt;&#xD;&#xA;&lt;img src=&quot;http://localhost/VISUIClients/_SupportFiles/avatar2.png&quot; height=&quot;50px&quot; width=&quot;50px&quot;/&gt;&#xD;&#xA;&lt;hr&gt;" />
            <Remark>
              <CalculatedColumn Formula="(&quot;@Data.Column2~&quot;).replace(/(&lt;([^&gt;]+)&gt;)/gi, &quot;&quot;)" ID="Column2" />
            </Remark>
          </DataLayer>
          <DataTableColumn Header="Column1" ID="colColumn1">
            <Label Caption="@Data.Column1~" ID="lblColumn1" />
            <DataColumnSort DataColumn="Column1" />
          </DataTableColumn>
          <DataTableColumn Header="Column2" ID="colColumn2">
            <Label Caption="@Data.Column2~" ID="lblColumn2" Format="HTML" />
            <DataColumnSort DataColumn="Column2" />
          </DataTableColumn>
        </DataTable>
        <Button Caption="export" ID="btn">
          <Action Type="PDF" ID="act">
            <Target Type="PDF" ExportDataTableID="dt" Report="CurrentReport" />
          </Action>
        </Button>
      </Body>
      <ideTestParams />
    </Report>

    web

    pdf

    0
  • Seema Verma

    Hi VISUI,

    Thanks, But the problem is when we take an export of the table it causes this type of an error , this time its related to hr because i used one dummy table with dummy row , but sometimes it happens with img . it generally happens with all those tags which are not compulsory to close in HTML . but logi throws an error while exporting like excel.

    I used one dummy table with below mentioned data :

    I got this error -

    But if iam modifying the data by adding hr closing tag , then i am able to take an export in excel .

     

    0
  • VISUI

    Logi's engine generally uses XSHTML not HTML.  You should ALWAYS close your HTML tags when adding any HTML elements within Logi.  If you were to do an AJAX refresh on an element displaying invalid XSHTML, you will most likely get an error as well.

    https://www.w3schools.com/html/html_xhtml.asp

    The following Report demonstrates this.

    <Report ID="LogiForum.RefreshInvalidHTML">
      <Body>
        <HtmlTag HtmlTagName="div" ID="html1" HtmlTagText="HTML1">
          <HtmlAttributeParams style="background-color: silver; height: 200px; width: 400px; margin: 20px;" />
          <IncludeHtml Html="&lt;h1&gt;Not valid XSHTML @Function.DateTime~" />
        </HtmlTag>
        <Button ID="btnRefresh1" Caption="Refresh HTML1">
          <Action Type="RefreshElement" ElementID="html1" ID="are1" />
        </Button>
        <HtmlTag HtmlTagName="div" ID="html2" HtmlTagText="HTML2">
          <HtmlAttributeParams style="background-color: silver; height: 200px; width: 400px; margin: 20px;" />
          <IncludeHtml Html="&lt;h1&gt;Valid XSHTML @Function.DateTime~&lt;/h1&gt;" />
        </HtmlTag>
        <Button ID="btnRefresh2" Caption="Refresh HTML2">
          <Action Type="RefreshElement" ElementID="html2" ID="are1" />
        </Button>
      </Body>
      <ideTestParams />
    </Report>

     

    0

Please sign in to leave a comment.