Author Topic: How to reject a redundant <br>  (Read 3459 times)

Hidehiro Ishii

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 44
    • View Profile
How to reject a redundant <br>
« on: November 30, 2017, 07:16:04 am »
Hi Team,

I use PQ Grid Pro 4.0.2 with WordPress 4.9.1 & Advanced Custom Fields Pro 5.6.6.
When I Select dataType "html" or "string" or "stringi", a redundant <br> is added automatically.
So a blank line of unwanted is displayed on grid.
Please let me know how to reject a redundant <br>.

Regards,
Koichi
 

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: How to reject a redundant <br>
« Reply #1 on: November 30, 2017, 03:37:08 pm »
<br> are added automatically when there are line breaks ( \n, \r, \r\n\ ) in the cells.

Do you have line breaks in the cells?

If there are line breaks at end of text and you don't need them, then you can remove them by trimming the text with $.trim() either before displaying or in the column.render callback.

Hidehiro Ishii

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: How to reject a redundant <br>
« Reply #2 on: December 01, 2017, 09:58:00 am »
Hi Team,

Thank you for your answer.
I understand that the $.trim() is useful to reject line breaks with a single line text.
But I want to display a multi line text as follows.

This is a sample text line1 <br>
This is a sample text line2 <br>
This is a sample text line3 <br>

On this case, The $.trim() can not reject all line breaks.
Please let me know how to solve on this case

Regards,
Koichi
   

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: How to reject a redundant <br>
« Reply #3 on: December 01, 2017, 03:49:51 pm »
<br> are not reduntant, they are means to display new lines in html.

As per my understanding, you don't need new lines or simply want to ignore them.

you want to display this

This is a sample text line1
This is a sample text line2
This is a sample text line3

as

This is a sample text line1 This is a sample text line2 This is a sample text line3

In that case you would need to override internal function of pqgrid by adding this to your code.

Code: [Select]
    pq.newLine = function(dataCell){
       return dataCell;
    }
« Last Edit: December 01, 2017, 03:55:23 pm by paramquery »

Hidehiro Ishii

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: How to reject a redundant <br>
« Reply #4 on: December 02, 2017, 01:07:23 pm »
Hi Team,

Thank you for your reply.
But the answer is different from what I want.
I want to display a multiline string without blank line with PQGrid.
I will show a example as follows.

$string="
This is a sample text line1 <br>
This is a sample text line2 <br>
This is a sample text line3 <br>
"

Normal HTML shows $string as follows.
--------------------------------------------------
This is a sample text line1
This is a sample text line2
This is a sample text line3
--------------------------------------------------

But PQGrid shows $string as follows
--------------------------------------------------
This is a sample text line1
                                           <- blank line
This is a sample text line2
                                           <- blank line
This is a sample text line3
--------------------------------------------------

Please let me know how to display $string as normal HTML with PQGrid.


Regards,
Koichi


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: How to reject a redundant <br>
« Reply #5 on: December 04, 2017, 08:12:14 am »
Please share a jsfiddle so that I can check the issue faced by you.

Hidehiro Ishii

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: How to reject a redundant <br>
« Reply #6 on: December 04, 2017, 11:53:45 am »
Hi Team,

Thank you for your reply。
I have never used jsfiddle.
So I will study to use jsfiddle and make sample code.
Please wait a few days.

Regards,
Koichi

Hidehiro Ishii

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: How to reject a redundant <br>
« Reply #7 on: December 11, 2017, 08:02:54 am »
Hi Team,

I have found out to solve my problem.
I should use strip_tags() instead of $.trim().
Please close this case.
Thank your cooperation.

Best Regards,
Koichi