Is there a quick way to apply a style to a COLUMN in a table

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Is there a quick way to apply a style to a COLUMN in a table

Post by ChoccieMuffin »

I am using the same info to produce two different PDF outputs, with two separate style sheets.

I am using tables fairly extensively (despite advice very early on to avoid if at all possible!) and I have figured out that you can set the style for the first column which applies a uniform width, by adding a sub-class to <col>, which works pretty well with setting a table style (in the standard style thingy, not any fancy table stylesheet) that sets the width to 100%, so using the whole of the available width, which is what I want. That column width bit has proved very handy, as in the stylesheet that uses a small font I can set the width to, say 15mm, and with the stylesheet that uses a larger font I can adjust that to 20mm. Lovely.

BUT... is there an easy way in the Flare interface to either SEE what column style is being used or to CHANGE what column style is being used? It would be really handy to be able to check through my files to ensure that I have a) applied a column style rather than just messing about formatting column widths individually and b) applied the correct column style.

Your tips would be very much appreciated, and if there isn't a way of doing so I feel an enhancement request coming on, as I use tables A LOT, seeing as there's no such thing as a hanging indent and a tab in html...

Thanks in advance
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by LTinker68 »

ChoccieMuffin wrote:... is there an easy way in the Flare interface to either SEE what column style is being used or to CHANGE what column style is being used?
Short answer, no.

The <col> tag isn't normally added to the topic until you set a width on a column, and the only way to apply a style to that tag is to open the topic in the Internal Text Editor and manually type in the class. Although the XML Editor allows you to select a whole column, it only shows td and th styles in the Styles pane, so the only way to tell if a class is applied is if A) the class changes the cells in that column in a noticeable way (e.g., applies a background color), or B) you open the topic in the Internal Text Editor and look for the tag. You can't even see the tag when the XML Editor is set to XML tag view.

So submit a feature request at http://www.madcapsoftware.com/bugs/submit.aspx.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by ChoccieMuffin »

How did I know it'd be you who answered? :wink:

Not quite what I wanted to hear but not surprised I'm hearing it, so enhancement request has been submitted.

Do you think doing this with tables is a sensible approach to take when working with simple tables? I'm not looking to have anything complicated like merged cells, different coloured rows etc, I'm just using tables to help with the "look" of the final thing.
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by LTinker68 »

ChoccieMuffin wrote:How did I know it'd be you who answered? :wink:
Because you figured out I have no life? :P

Yeah, I tend to go with the simple tables, especially if I'm merging cells. You can always create tr or td classes and apply them to simple tables, so you can make them look as though they were created using the table stylesheets. It just takes a bit more effort to create them, and you have to manually fix alternating row/column colors when you add/remove rows/columns.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by ChoccieMuffin »

I was wondering about the more general approach of defining table classes e.g. <table.regular> with the left margins and widths set, and then <th> classes, <tr> classes and putting <p.tabletext> paragraphs inside the cells, and then also having the <col> classes to allow me to set the width of a column, or am I hitting a teensy little nut with a bloomin' great big sledgehammer?
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
i-tietz
Propellus Maximus
Posts: 1219
Joined: Wed Oct 24, 2007 4:13 am
Location: Fürth, Germany

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by i-tietz »

If you could apply some regularity to your tables there would be a way. You would need somebody who knows his way around javascript (js). With js you can use regular expressions for search and replace. You would need a js that is triggered "onload". In the stylesheet you would need a few classes for tables. let's say:
table.col1
table.col2
etc.

If you want to assign a certain style to the second colum of a table, you assign the class "col2" to the table, if you want to assign a certain style to the third colum of a table, you assign the class "col3" to the table, and so on.
Find out what your needs are and generate teh necessary classes.

This is the start of the script - put it into the header of your masterpage or topic template:

Code: Select all

<script type="text/javascript">
<!--
window.onload = functionname;

functionname () {
The rest of the js would need to execute a search and replace with regular expressions. The source code of a topic looks like this

Code: Select all

<table class="col2">
                <col />
                <col />
                <tbody>
The js would have to change it into sth like this

Code: Select all

<table>
                <col />
                <col style="background-color: red;"/>
                <tbody>
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by ChoccieMuffin »

i-tietz, you have just scared the pants off me with that as I most certainly don't work with anyone who knows their way around javascript! :D

Working completely on my own on this one, so I have to rely on the skills, tips and tricks that I can pick up on my own (with the help of this forum, of course) so I'll just have to stick to the long and laborious way, but do keep posting tips like this as I'm sure they'll be of help to people who know a darn sight more than I do.
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
forfear
Propellus Maximus
Posts: 766
Joined: Sat Feb 16, 2008 3:37 am
Location: Jungle Jingles

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by forfear »

ChoccieMuffin wrote:i-tietz, you have just scared the pants off me with that as I most certainly don't work with anyone who knows their way around javascript! :D

Working completely on my own on this one, so I have to rely on the skills, tips and tricks that I can pick up on my own (with the help of this forum, of course) so I'll just have to stick to the long and laborious way, but do keep posting tips like this as I'm sure they'll be of help to people who know a darn sight more than I do.
Styling tables
Do consider creating a simple table style. Its worth the effort. and apply it to the table. (optional)

In your main stylesheet (not the table style) look for a 'td' tag and create a class like td.pink.
With the table structure bars, select the column, right-click and select Cell Content Style. You'll be able to select and apply the background colour for the column you want.
Snap3.png
Done
Snap4.png
You do not have the required permissions to view the files attached to this post.
If you submit your bug feedback request here, the more likely it'll get fixed or included in a future release
Open Utilities PageLayout Resizer for Flare/Blaze | Batch builder
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by ChoccieMuffin »

This is exactly what I was looking for, in the absence of being able to set the width for a whole column using the XML editor and Flare interface. If I have a table with several rows and I highlight the column by clicking the structure bar for the column at the top and then apply a <td> style, will that apply it to all the selected cells? Fingers crossed.

I know I'm now going to have to hunt through my project to take off those <col> things and stick in <td> things instead, now that I've included them in my stylesheet, but it's the interface thing that I was looking for. Shame I couldn't find out about this from the thousands of pages of user docs, perhaps you DO still need to write that book! ;)
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by LTinker68 »

A <td> tag only applies to a single cell. You can apply a class to all the cells in a column by selecting them all, but you can't click on a column block at the top of the XML Editor or a single td block on the left of the editor, apply a style, and have it applied to all the cells in that column or row. You have to multi-select the cells and apply the style. Good news is that if you insert a row then it'll include that style in the new row or column.

Also, be careful trying to override style definitions for td tags in a table that has a table stylesheet applied to it and that has alternating row and column colors -- you can apply your class, but if you add a row or column Flare will redraw the table with the original table stylesheet specifications, so your td class will be blown out. If you don't have alternating row and column colors then it may not be an issue with table stylesheets.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by ChoccieMuffin »

Hmm... not sure what's going on here, but it didn't work in setting the width of the column.

I have defined the following in my stylesheet (nothing in <td>):

td.NoteHead
{
width: 15mm;
}

and

table.TableRegular
{
border-collapse: collapse;
width: 100%;
}


and here's my code from my topic:

<table class="TableRegular">
<tr>
<td class="NoteHead">
<p class="NoteHead">Note:</p>
</td>
<td style="" class="tdNonbreaking">
<p class="Note">In addition to the general settings in the <span class="variableOptions"><MadCap:variable name="Options.App_Settings"></MadCap:variable></span> menu, many applications have addtional settings that you can configure. See the sections on individual applications for details.</p>
</td>
</tr>
</table>


BUT, in the XML interface, in the structure bar across the top both columns show the width as "auto", rather than the first one being "15mm", so the column's only a wide as the word within it.

Am I doing something stupid or should I just stick with the <col> hack? Glad I tried it out before going through the whole thing!
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
i-tietz
Propellus Maximus
Posts: 1219
Joined: Wed Oct 24, 2007 4:13 am
Location: Fürth, Germany

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by i-tietz »

ChoccieMuffin wrote:Hmm... not sure what's going on here, but it didn't work in setting the width of the column.
<table class="TableRegular">
<tr>
<td class="NoteHead">
<p class="NoteHead">Note:</p>
</td>
<td style="" class="tdNonbreaking">
<p class="Note">In addition to the general settings in the <span class="variableOptions"><MadCap:variable name="Options.App_Settings"></MadCap:variable></span> menu, many applications have addtional settings that you can configure. See the sections on individual applications for details.</p>
</td>
</tr>
</table>
The red code interferes: It doesn't work if you have <p> tags inside the <td> ...
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by ChoccieMuffin »

Nope, it's not that. I've just removed the <p> and </p> items from both of the table cells, and the only thing that changed was the formatting relevant to the <p> classes was removed, the width of the first column stayed as auto and not 15mm wide.
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
i-tietz
Propellus Maximus
Posts: 1219
Joined: Wed Oct 24, 2007 4:13 am
Location: Fürth, Germany

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by i-tietz »

Very often you need to initialize the tags.
Try to have this in the stylesheet before the td.NoteHead

Code: Select all

table, th, tr, td {}
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by LTinker68 »

You shouldn't need to initialize the tags.

You may be compounding the issue with the table class. You don't want to specify width on the table and all of its columns -- you need to have at least one column not have a set width, otherwise it's too easy to get in a conflict between how wide the table class wants to be and how wide each of the columns wants to be. If the NoteHead class is the only one with a set width then you should be fine, unless the table is inside another element that's limiting how wide it can go, or the content in the other column can't be compressed enough to allow the first column to go its full width.

Note also that it depends on which medium you specified that width in and which view the XML Editor is in. For instance, if you specify 15mm in the print medium but you're looking at it in web layout then you won't see the effect because you didn't specify a width in the default medium (or you specified a different width for the default medium). Does it look ok in the compiled output and it's just the editor where it doesn't look right? Also, I'm not sure if browsers know what to do with millimeters, since that's generally a print unit of measure. They might be able to do the conversion, but I tend to stick with pixels for widths and positions in online output and use inches or points (or mm in your case) for the print medium.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by ChoccieMuffin »

LTinker68 wrote:You shouldn't need to initialize the tags.

You may be compounding the issue with the table class. You don't want to specify width on the table and all of its columns -- you need to have at least one column not have a set width, otherwise it's too easy to get in a conflict between how wide the table class wants to be and how wide each of the columns wants to be. If the NoteHead class is the only one with a set width then you should be fine, unless the table is inside another element that's limiting how wide it can go, or the content in the other column can't be compressed enough to allow the first column to go its full width.

Note also that it depends on which medium you specified that width in and which view the XML Editor is in. For instance, if you specify 15mm in the print medium but you're looking at it in web layout then you won't see the effect because you didn't specify a width in the default medium (or you specified a different width for the default medium). Does it look ok in the compiled output and it's just the editor where it doesn't look right? Also, I'm not sure if browsers know what to do with millimeters, since that's generally a print unit of measure. They might be able to do the conversion, but I tend to stick with pixels for widths and positions in online output and use inches or points (or mm in your case) for the print medium.
The outputs I'm working with are both PDF, so mm is appropriate for widths. When I'm working, I use web medium for just typing stuff in (because you can zoom in with much more granularity and with a teensy font and my eyes not being what they once were it's a bit tough only having 100% as the max when viewing the print medium) and print medium for when I want to look at layout. And I either preview the compiled topic or generate the whole thing again if I want to check things carefully. I also find that you sometimes need to switch to the other medium and back again to get the screen to refresh (which is a bit of a pain but other things are a lot more painful).

The only attribute set for the table class is that it's 100% width, rather than a specific width in pixels, mm or any other unit of measurement. I have set the width for the first column (where the word "Note:" goes) to be a set width, so that every time I want to insert a note, it looks the same. I used paragraphs inside the table cells because that's what I'm used to, and also because there are other table cells, for example when I have a pile of instructions that I want to have a picture beside, that need to have separate paragraph and list styles. I don't have any tables where ALL the columns have widths defined, there's at least one that's "width=auto".

Anyhow, I think I'll have to stick with <col> rather than <td> as it is specifically the column width I want to set, not just the width of the cell.

Just for completeness, here's the code for same paragraph that does seem to work.
<table class="TableRegular">
<col class="Note" />
<col />
<tbody>
<tr>
<td>
<p class="NoteHead">Note:</p>
</td>
<td>
<p class="Note">In addition to the general settings in the <MadCap:variable name="Options.App_Settings" class="UI" /> menu, many applications have additional settings that you can configure. See the sections on individual applications for details.</p>
</td>
</tr>
</tbody>
</table>
Last edited by ChoccieMuffin on Tue Jul 13, 2010 2:19 pm, edited 1 time in total.
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by LTinker68 »

ChoccieMuffin wrote:I also find that you sometimes need to switch to the other medium and back again to get the screen to refresh (which is a bit of a pain but other things are a lot more painful).
FYI, pressing F5 while the cursor is in the topic will also refresh it.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
i-tietz
Propellus Maximus
Posts: 1219
Joined: Wed Oct 24, 2007 4:13 am
Location: Fürth, Germany

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by i-tietz »

LTinker68 wrote:You shouldn't need to initialize the tags.
True - you shouldn't ... but I know I had to do that in a project where we need a lot of specific classes, e.g. for different sorts of <div>s or dropdowns ( = Flare-specific kind of div): I had to have a declaration for the simple <div> or dropdown (= without classes) to make the styles work.
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Is there a quick way to apply a style to a COLUMN in a table

Post by LTinker68 »

Never had to do that even for the Flare features. If you don't specify anything it should use the default DIV styles or whatever declarations are specified for the DIV in the MadCap.css stylesheet by default. I've had to specify a div or div class in my stylesheet to override a setting in MadCap.css, but I've never had to add an empty div just to be able to use a feature. Interesting.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
Post Reply