First off, I'm using version 3.7.1 with a jQuery UI framework theme. I'm trying to figure out how to have a newline or even a <br /> render inside of a jqGrid cell.
An example of what I'm looking to have happen:
________________________________________________________
Item 1 | some data | Applies to OS 1
Applies to OS 2
Applies to OS 3
Applies to OS 4
__________________________________________________________
Item 2 | some data | Applies to OS 1
__________________________________________________________
Item 3 | some data | Applies to OS 4
Applies to OS 5
__________________________________________________________
What currently happens when my data has either a <br /> or a \n is:
__________________________________________________________
Item 1 | some data | Applies to OS 1Applies to OS 2Applies to OS 3Applies to OS 4
I would rather not have to use an actual <br /> tag, since I'd rather not have HTML embedded in my data, but am willing to do whatever I have to since I NEED to render this data as a list of values. Thanks for any help.
You should use custom formatter (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter) for the column where you need to have <br />. This allow you to defina any HTML fragment for a column. See jqGrid: Editable column that always shows a select as an example.
Probably Wrapping Text lines in JqGrid will be also helpful for you.
P.S. If you will have problems with the usage of custom formatter, post a column definition and a raw data example (JSON data for example) for the column where you want have <br/>
Related
Using Bokeh to display charts within Flask my hovertools works except for dates, which are my x axis in all charts. I have tried a hundred permutations of the code and extensively reviewed the documentation and related questions but am missing some key element on how to use formatters within custom html. This question seems to address my exact question, but I do not see how the answer relates to the actual custom html:
bokeh hover tool - format date variable in custom html
The data is passed to bokeh as a pandas data frame then use ColumnDataSource within Bokeh. The index, and x values, are definitely datetime with Bokeh treating them as a datetime in other parts of the charting such as the x axis labels and ticks.
This is my current hovertools html within Python:
def create_hover_absolute():
"""Generates the HTML for the Bokeh's hover data tool on our graph."""
hover_html = """
<div class="plot-tooltip">
<div>
<span style="font-weight: bold;">$name</span>
</div>
<div>
$y{$,000}
</div>
<div>
Date: #date{%Y-%m}
</div>
</div>
"""
return HoverTool(tooltips=hover_html, formatters={'date': 'datetime'})
I have tried a variety of ways to enter the date including:
$x
$x with all sorts of formatting such as {%Y%b}
#date
# date with all sorts of formatting
I end up with the date as either a long integer (15 digits) or a mysterious three digit number with TIB. Like this:
screenshot showing hover with Date: 118TB%
I can make all of this work on the local Bokeh server when I do show(plot) but not in the custom html when passing to web page. How do I format the date within the html? How do I include the formatters?
thank you
All I needed to do, as pointed out in comment by Eugene Pakhomov was to change 'date' to '#date' in the formatters. Like this:
return HoverTool(tooltips=hover_html, formatters={'#date': 'datetime'})
I'd like to have to have cells of a python notebook on 2 columns, for writng annotations next to code (for example, instead of inserting 2 cells below, I would insert I insert a cell on the right and a cell below on the left)
I know that it's possible to use custom css for changing the appearance (e.g https://github.com/nsonnad/base16-ipython-notebook/blob/master/ipython-3/output/base16-3024-dark.css ), is it possible also for the layout?
On the other hand, I found an example of how to use the css for creating a table layout (https://pixelsvsbytes.com/2012/02/this-css-layout-grid-is-no-holy-grail/), but not being very familiar with CSS I don't understand if this can be applied to an unknown number of equal blocks (unknown because they are generated interactively by the user). For reference, here is how currrently looks like:
You could just change the cells to markdown or raw and make them float right.
from IPython.core.display import HTML
HTML("<style> div.code_cell{width: 75%;float: left;}"
+"div.text_cell{width: 25%;float: right;}"
+"div.text_cell div.prompt {display: none;}</style>")
Now when you enter a cell and want it on the right press esc-r (or m).
esc- unselects it and allows the notebook to process commands. r is the command to make a raw cell.
I have created a custom auto report (by clicking file > print - then modify to create new) with various fields but when physically printing the report, the first column wraps the text so it looks something like this:
Item # | Item Name | Qty
--------------------------
5439988 | Test Item | 2
0049E
Other columns do not wrap text like this, is there any way of changing the column widths to stop this kind of behaviour so i can improve the aesthetics of the report?
Check the DisplayLength attribute on the extended data type of the corresponding field.
I want to change these values with DataFormatString properties in Gridview.
1.000000 --> 1 --> Deleting all digits after .
366705.000000 --> 366,705 --> Deleting all digits after . and put the comma for seperate.
12.830000 --> %12,83 --> Delete last 4 digits after . and put % (% is optinal not must)
BTW, Is there any link to suggest me otherwise DataFormatString. I analyze very well this page but sometimes still can't find what I need about data format string.
Here you go. I didn't test #3 - if it's not right, it's close.
1
Convert the number to an int.
2
String.Format("{0:n"}, 366705);
3
(12.83 / 100).ToString("{%#0.00}", el-GR);
A couple helpful formatting web pages:
Custom Numeric Formatting
SteveX Compiled - blog with many samples
Say I have an input stream consisting of lines separated into a certain number of fields. I would like to cut on the various fields, pipe a certain field (or fields) to a program (which is assumed to return one line for each input line) and leave the other fields as is, and paste the results back together. I can probably imagine convoluted solutions, but there ought to be a clean and natural way to do that.
As a specific example, say I have a program producing lines of the form:
$ inputprog
<a> hello world!
<b> hi everyone!
<a> hi!
Say I would like to put the message in uppercase while leaving the first field unchanged. Here is how I would imagine things:
$ inputprog | program -d' ' -f2- "tr a-z A-Z"
<a> HELLO WORLD!
<b> HI EVERYONE!
<a> HI!
I am looking for a reasonably clean way to approximate program. (I am not interested in solutions which are specific to this example.)
Thanks in advance for your help!
awk can do what you want. For example:
$ echo "field1 field2" | awk '{$2 = toupper($2); print;}'
field1 FIELD2
Comes pretty close to what you want to do. $2 = toupper($2); changes the second field, while print prints out the whole (modified) line.
However, you got a problem in how you define a 'field'. In the example above fields are separated by spaces (you can change the field separator to an arbitrary regexp with like so: -F'<[a-zA-Z]+>' - this would consider as a field separator).
But in your example you seem to view <a> as one field and hello world! as another one. Any program could only come to your desired behaviour by wild guessing that way. Why wouldn't world! be considered a third field?
So, if you can get input with a clear policy of separating fields, awk is exactly what you want.
Check out pages like http://people.cs.uu.nl/piet/docs/nawk/nawk_92.html (awk string functions) and http://www.pement.org/awk/awk1line.txt (awk 1 liners) for more information.
BTW, one could also make your specific example above work by looping over all the fields except the first one (NF == Number of Fields):
$ echo "<a> hello world!
<b> hi everyone!
<a> hi" |
awk '{for(i=2;i<=NF;++i) { $i=toupper($i); }; print;}'
<a> HELLO WORLD!
<b> HI EVERYONE!
<a> HI
Even though you are not interested in the solution to this example. ;-)
P.S.: sed should also be able to do the job (http://en.wikipedia.org/wiki/Sed)