Darren, i am using the razor syntax... basically, i need to be able to assign row span based on the <th colspan="4"> attribute - i have a collection of cases... but i am getting somewhat confused.
here is a sample of the markup from the rich text editor...
<table border="0" cellspacing="0" cellpadding="0"> <thead> <tr> <th colspan="4">How Much You Pay for a Covered Prescription Drug in 2012</th> </tr> </thead>
<tbody> <tr> <th> </th> <th class="ctr" colspan="2">Retail Pharmacy<br /> (up to a 30-day supply)</th> <th class="ctr">Medco By Mail<br /> (up to a 100-day supply)</th> </tr>
<tr> <th> </th> <th>First Three Fills</th> <th>Each Subsequent Refill</th> <th> </th> </tr>
I don't really understand what you are trying to do based on the description above - but if the 4 in <th colspan="4"> is variable and you want to do some output based on the value then you'd need to modify the ParseRichText function to take a second parameter e.g. ParseRichText(node.ChildNodes, 4)
the client is creating tables in the rich text editor - they are able to have cells span multiple rows, etc. [see markup above as a generic example]
The challenge comes in when parsing to PDF using the razor examples you have provided. I was able to add case statement to handle the table nodes, etc. but have no idea how to handle a rowspan element on the node to translate that into some xsl:fo syntax to make it work for any tables rendered by the engine.
does that help? I am actually struggling with this aspect on TWO sites right now and imagine it will continue to come up... so the ability to have a solution for table rendering would be great.
okay, i did not need braces... i am getting closer... no i am getting this error
Type of conditional expression cannot be determined because there is no implicit conversion between 'string' and 'char' at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
from this line
var rowSpan = (node.Attributes["colspan"].Value != null ? node.Attributes["colspan"].Value : '2');
question about table row attributes
so, i am getting a little up the road on making some helpers for rendering tables... however, here is my issue...
i am rendering a cell that sould span multiple columns i can specify the
fo:table-cell number-rows-spanned=""
but what i want to know is how would i parse the attribute for colspan="" on the actual html table?
any thoughts?
Hi Bob,
Are you writing XSLT or Razor? are you parsing HTML tables from a rich text editor and trying to turn them into fo tables?
Darren, i am using the razor syntax... basically, i need to be able to assign row span based on the <th colspan="4"> attribute - i have a collection of cases... but i am getting somewhat confused.
here is a sample of the markup from the rich text editor...
and here are my case statements...
I don't really understand what you are trying to do based on the description above - but if the 4 in <th colspan="4"> is variable and you want to do some output based on the value then you'd need to modify the ParseRichText function to take a second parameter e.g. ParseRichText(node.ChildNodes, 4)
to expand on the above...
the client is creating tables in the rich text editor - they are able to have cells span multiple rows, etc. [see markup above as a generic example]
The challenge comes in when parsing to PDF using the razor examples you have provided. I was able to add case statement to handle the table nodes, etc. but have no idea how to handle a rowspan element on the node to translate that into some xsl:fo syntax to make it work for any tables rendered by the engine.
does that help? I am actually struggling with this aspect on TWO sites right now and imagine it will continue to come up... so the ability to have a solution for table rendering would be great.
thanks,
bob
Hi Bob,
you can access the attributes of the original table like this:
case th:
@{ var rowSpan = node.Attributes["rowspan"].Value }
break:
Does that help?
i get a generic error when adding that to the th case
what am i missing?
here is what the trace shows...
Error loading MacroEngine script (file: , Type: ''
d:\HostingSpaces\SegalDev\psccunywf.org\wwwroot\App_Data\TEMP\Razor\inline-09096d6234f6338607892e620d0ef855.cshtml(171): error CS0839: Argument missing
at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
Does a th always have a rowspan? can you look at the temp file mentioned in the error and post line 171?
d:\HostingSpaces\SegalDev\psccunywf.org\wwwroot\App_Data\TEMP\Razor\inline-09096d6234f6338607892e620d0ef855.cshtml
If there isn't a rowspan you'd need to do a null check.
ah, there is not ALWAYS a rowspan... so let me try a null check
grrrr... i hate that i don't know razor :(
how do i write this null statement?
@{var rowSpan = string.IsNullOrEmpty(node.Attributes["rowspan"].Value);}
that is not working???
Untested 'cos i don't have Umbraco installed on this PC but something like:
bob,
try node.Attributes["rowspan"]!=null as I suspect you wont have it at all and therefore it cannot test value.
Regards
Ismail
still get the same error - and the error is on this line...
@{var rowSpan = (node.Attributes["rowspan"] != null ? node.Attributes["rowspan"].Value : 1);}
any more thoughts?
Bit of a shot in the dark, is it possible to use node.HasAttribute("rowspan")?
okay, the issue is something completely different...
this statement even throws an error... why?
@{var rowSpan = 7}
still says an argument is missing?
okay, i did not need braces... i am getting closer... no i am getting this error
Type of conditional expression cannot be determined because there is no implicit conversion between 'string' and 'char'
at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
from this line
var rowSpan = (node.Attributes["colspan"].Value != null ? node.Attributes["colspan"].Value : '2');
Change the '2' to "2" perhaps?
J
Thanks so much Jason!
what a great community effort on this one... i am slowly learnign more and more each day... and this thread was a huge help!
thanks to all... so... to close the loop, here is what it all looked like in the end...
so basically, we are checking for a colspan in the RTE table, if it exists, use the value, if not... set it to 1 - what a cool little app this is ;)
is working on a reply...