Line breaks, paragraphs, etc. in table cells?

Line breaks, paragraphs, etc. in table cells?

raintonrraintonr Posts: 2Questions: 0Answers: 0
edited November 2009 in General
Firstly thanks - I'm completely loving this plugin and am using it for a couple of server side tables.

One of these though, I'd like to have an large-ish image with some text below in the table cell. You'd normally do this with:

[code]




Here's some text.


[/code]

Or

[code]



Here's some text.


[/code]

However, returning br or p tags in the server side function seems to break the table redraw.

Searching this forum I found another thread where someone was advised to remove all \n \r
, etc. from their server side return.

Just curious as to why this is? Is there intentionally no support for this in cells or is it something we could work on (I'm happy to have a poke around in the code and try and product a patch if required)?

If this is not supported, perhaps I can have my server side function embed a dummy attribute in the img tag and then have a post-processing piece of Javascript go though the cells later, pulling these attributes out and placing them below the image.

Any thoughts?

Thanks again,

Rob

Replies

  • izzy6150izzy6150 Posts: 49Questions: 0Answers: 0
    Hi Rob,

    I ran into this problem last week and found that if any of your code should return any ' or / then it seemed to fail. the way i solved this was to force my server side script to output \' and \/ which i believe are the javascript escape versions. but this worked for me.

    Regards,
    Izzy
  • raintonrraintonr Posts: 2Questions: 0Answers: 0
    Thanks for the follow up. I perceived and discovered that yes, if one removes the line breaks
    tags are acceptable.
  • allanallan Posts: 61,971Questions: 1Answers: 10,160 Site admin
    Hi raintonr,

    The issue that you are facing is that Javascript has really poor support for multi-line variables. For example:

    [code]
    var allan = "this is
    my name";
    [/code]
    is invalid, but if you put a "\" at the end of the first line it would work. So the problem you are encountering is that the JSON string returned from the server cannot have newline characters in them (unless properly escaped) otherwise that JSON parsing will fail.

    What I really which Javascript had, was something like Perl's heredoc syntax :-)

    Hope this helps,
    Allan
  • dprescheldpreschel Posts: 1Questions: 0Answers: 0
    edited February 2010
    I've run across a similar issue and have tried to fix it. What I want to do is put a blank line (or table row) at a point where the sorted column's data changes. For example:

    teacher name 1 - class name - date of class
    teacher name 1 - class name - date of class
    teacher name 1 - class name - date of class

    teacher name 2 - class name - date of class
    teacher name 2 - class name - date of class

    and so on. I would like there to be a blank row put in between the different teachers 1 and 2 (and 3, etc). I tried a few things but have been unsuccessful so far.

    Sorry if that didnt make sense! Datatables really is a great product, and I've been amazed at how much I have been able to do with so little code!

    Thanks, Dave
  • allanallan Posts: 61,971Questions: 1Answers: 10,160 Site admin
    Are you using client-side processing or server-side?

    If client-side you could do something like this: http://datatables.net/examples/advanced_init/row_grouping.html . If server-side, then you could just insert a blank set of TR / TD elements where needed by parsing through the result set.

    Allan
  • allanallan Posts: 61,971Questions: 1Answers: 10,160 Site admin
    Oo - another option... You could add a specific class to the row where you detect a change, and just have the padding-top for that row quite high...

    Allan
This discussion has been closed.