Underline all text in a row of an R dataframe - r

I'm building a shiny app and I want to emphasize a summary row in some of my dataTable outputs. I would like all the values in the second to last row to be underlined. I'm not strong enough with HTML or CSS to know where to start with this. I've looked through a bunch of DT style guides but can't find anything helpful

You can paste an underline tag around the entries you want to underline, then set escape = FALSE in DT.
escape property in DT: https://rstudio.github.io/DT/ see section 2.10 Escaping Table Content
Example of adding tags around some content: paste0("<u>", "original content", "</u>")

Related

open html/css file with MS Word - element table - apply no text wrapping

I am looking to open an HTML/CSS file with MS Word. I have a table in the file and would like to set the table properties, text wrapping to NONE using CSS. I understand Word should be able to interpret the HTML/CSS.
I cannot find any CSS to apply NO text wrapping to an entire table. Can anyone help?
If you are writing your styles separately, you can define your css as such:
table th,
table td {
white-space: nowrap;
}
That is going to make ALL table header and regular cells not wrap, so be aware of that. If you are trying to make this change and you need to target a cell directly, you would have to make the above CSS more specific by adding class names to the cells you want to target. Or add the CSS inline to the cell: <td style="white-space:nowrap"></td>

how to underline a letter of button caption in vaadin?

I'm using keyboard shortcuts in my Vaadin application. So i want to highlight one letter in button caption. The underline might be for first or second or third letter of the caption.
I am able to underline the first letter by using the "first-letter" property of CSS. How to underline second or third letter?
NativeButton btn = new NativeButton("Edit");
btn.addStyleName("myunderline");
.mytheme .myunderline.v-nativebutton::first-letter {
text-decoration: underline;
}
Is there any solution?
Thankyou!!!
So I want to highlight one letter in button caption...
You have not specified the vaadin version you are using. But latest vaadin 7 (> 7.4) versions support HTML in Button caption.
NativeButton nb = new NativeButton("<u>E</u>dit");
nb.setCaptionAsHtml(true);
Is posible to indicate it using & symbol during shortcut listener creation.
According Vaadin docs:
https://vaadin.com/docs/-/part/framework/advanced/advanced-shortcuts.html
// A field with Alt+A bound to it, using shorthand notation
TextField address = new TextField("Address (Alt+A)");
address.addShortcutListener(
new AbstractField.FocusShortcut(address, "&Address"));
Hope it helps.
Looks like there's no simple CSS solution, based on This Answer where someone is trying to do the same, and This Answer from the Vaadin forums.
Basically, your simplest option is to wrap the letter you want to underline in its own element which applies the underline:
<button ...>Te<span class=underline>x</span>t</button>
... Or something along those lines. The first link above has an answer which references a number of other JS libraries (lettering.js, nth-everything-css) which might be able to help you out.

Edit CSS of renderDataTable in R shiny

I am using R shiny to present data and want to move filter of datatable from bottom to top. I have already got answer from stackoverflow suggests to change CSS. But I am not familiar with CSS, can anyone tell me how to modify CSS in renderDataTable function? Thanks!
reference link: How to place DataTables column filter on top
I tried the following, but doesn't work:
output$obs <- renderDataTable({data()},
options = list(aoColumnDefs = list(list(fnFilter$tfoot(display = "table-header-group"))))
)
I'm not sure that's the best way to do it but you can "overwrite" the css of "tfoot" elements :
Using for example this line in your Ui :
tags$head(tags$style("tfoot {display: table-header-group;}"))
Though, it can be a problem if you have other tables with footer which you don't want at the top of the tables.

ipython notebook align table to the left of cell

I have below ipython notebook code (markdown):
#### example table
|Name|Description|
|--|-------------------------------|
|Mary |She is a nice girl.|
|Jackie |He is a very naughty boy.|
The output looks like below:
How can I:
Left align the table of the cell, it's center by default now.
Right align the second col text.
Well, yes !
| Name | Description | age
| :- |-------------: | :-:
|Mary| She is a nice girl. | 20
| Jackie Junior | He is a very naughty boy. | 5
:--- or --- = left align
---: = right align
:---: = centered
Answer to the 1st question - left-align the table - create and run a code cell above the table markdown cell, with the following content:
%%html
<style>
table {float:left}
</style>
I would suggest to use this variant of the knuth's answer that doesn't affect the flow of the remaining elements around the table. Put this code inside a cell above the one containing the table:
%%html
<style>
table {margin-left: 0 !important;}
</style>
You can make a custom preference in Ipython.
Just make the following file
~/.ipython/profile_default/static/custom/custom.css
and add the following code.
table {float: left};
and You don't have to put the custom css in all ipython files.
I know many have already answered this, but personally, I found their answer lacks a little more description, and because of this many are not able to implement this.
Clarification
Also, I want to clear one thing that I am not giving the solution for aligning the values inside the table but for aligning the whole table rendering itself. And if you are looking solution for the table's cell alignment then you can consider the first answer itself
Solution
Here are the steps:
First create a Code cell (not markdown) just above your markdown cell where you want to show your table.
Then write the following in your Code cell inside it.
%%html
<style>
table {float:left}
</style>
Run your Code cell.
Now just create your table as normally you do, no need to add anything extra. And Voila! Your table should now render to the left.
For every notebook, you have to do this step for changing the table alignment. But if you don't want to do this, you can follow #Anderson answer. For ease, I am copying his answer here.
First you need to create a file named custom.css where you will put the following code
table {float: left};
Then you have to move this file to your ipython directories, it will be something like this
~/.ipython/profile_default/static/custom/custom.css
Hope it helped 😊
Yeah, I don't like that centered table either. Insert this at the top of your notebook after the imports section:
from IPython.core.display import HTML
table_css = 'table {align:left;display:block} '
HTML('<style>{}</style>'.format(table_css))
The IPython.core.display namespace allows you to imbed audio, local filelinks among others - as well as HTML within your notebook.
!important overrides the css of rendered _html
Use your styles with !important
<style> table td, table th, table tr {text-align:left !important;} </style>
Answering the fist question: When creating a table and assigning it the float: left attribute you end up having to add more CSS to resolve the text that surrounds the table. Place this in a code cell before your markdown cell
%%html
<style>
table {
display: inline-block
}
</style>
However, if you have a lot of CSS, might be best to put it in another file for the overall beauty of the document.
#jrjc answers the 2nd question perfectly ;)
If you look at the table in the inspector, you'll see that the cause of the issue is the fact that the margin-left and margin-right CSS properties on the table are set to auto, making it centered. You can make it left-aligned by doing something like this in your custom.css:
.rendered_html table {
margin-left: 0px;
}
That should only left-align those specific tables and not affect anything else.

plone 4 new style collection filtering with "and" operator

I have been trying to use the new collection in plone 4.2.1 to filter a set of documents. I can not use the 'and' operator to get the result I need.
For example I have the following documents:
document1, tag 'yellow'
document2, tag 'yellow', 'red'
document3, tag 'red'
How do I filter the collection to show only document 2?
It's not possible with the new-style-collections, because of the missing and/or-operators. :(
It is not possible (the way you want), but I have made a (very ugly) hack (which also has some minor bugs (basically if the tag contains spaces) in collective.ptg.quicksand
1) the tags are added to the content as (css) classes
2) A javascript (or css file) hides those without the right class.
This would mean that document1 has 'div class"yellow"' and document2 has
div class="yellow red". Then you hide all the divs with css (or javascript) and shows document2 by
.red.yellow {display: block} or similar.
You can see the idea here :http://products.medialog.no/galleries/quicksand
(although here I have not made any tags containing both (red and yellow), but that should be just to remove the "split" in the init py file, line 82 here:
init.py">https://github.com/collective/collective.ptg.quicksand/blob/master/collective/ptg/quicksand/init.py

Resources