cellRenderer multi line <br/> and Line hight - ag-grid-react

I have 2 issues with ag-grid
My field has a ';' separator and I want to show in the cell each sentence on new line. for this I wrote a renderer:
const ServicesRenderer = (params: ICellRendererParams ) => {
return <span>{params.value.split(';').join('<br/>')}</span>;
};
it just shows '<br/>' instead of ; but no new line
The line height in any cell is 40px. I changed in my css :
.ag-cell {
line-height: normal;
}
but it doesn't make the lines smaller.
Can anyone help?
Thank you

I changed the renderer to: return <div>{params.value.split(';').map(s => <><span>{s}</span><br /></>)}</div>; and it works. not sure why.
I changed the defaultColDef to have cellStyle: { lineHeight: 'normal'} and that did it. Again not sure why id did not work with a class.
Thank y'All :-)

Related

How to make text in vaadin Grid cell to wrap

I need to make Vaadin 8 Grid cell text wrap. I tried to follow this link in Vaadin Forum.
https://vaadin.com/forum/thread/16908210/vaadin-8-grid-wrap-long-lines
My Grid contains Strings only in every cell.
I have a StyleGenerator class like this:
public class MyGridStyleGenerator<ArrayList> implements StyleGenerator {
public String apply(Object item) {
return ".m-grid-cell-wrapper";
}
}
I am converting from Vaadin 6 so I still use old theme ("../reindeer/legacy-styles.css")
In my styles.css file, there is:
.m-grid-cell-wrapper {
word-wrap: break-word;
white-space: normal;
}
In the class that creates the Grid, I have:
Grid<List<String>> table = new Grid<>("My Test Grid");
//skip setting items code since the cell content shows up fine.
MyGridStyleGenerator style = new MyGridStyleGenerator();
table.setStyleGenerator(style);
table.setBodyRowHeight(35); // more than two lines of text height
I set each column width to a fixed value using setWidth() of Grid.Column so that more columns can be displayed in the given window.
The problem is that when the Grid is displayed, text longer than column width does not wrap.
What did I miss?
Thanks for any advice.
BTW, there is another question on this topic in Stack Overflow where the answer is to use label.setStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
I don't have Label and don't use Valo style.
The CSS class controlling the Grid cell is .v-grid-cell, so I added the following in my styles.css file.
.v-grid-cell {
white-space: normal; }
This caused the text in Grid cell to wrap.

dimple tooltip too wide

I am using dimple.js on a mobile device but when the text is too long for the tool tip is just goes off the screen instead of wrapping down. Is there a way to set a maximum width for the tooltip? I am currently using this code to show only certain info:
s.getTooltipText = function (e) {
return [
"Product Description: " + e.aggField[0],
"Volume: " + e.yValue
];
};
Thanks!
The quick and dirty way would be just to use CSS:
.dimple-tooltip{
width: 200px !important;
}
Note that this won't auto-wrap text though.

Telerik grid and large cells

I have problem with ASP.NET MVC Telerik Grid.
In my grid I have comment column and some columns contains too large text.
This effects to row height. I need that all rows have same height.
How I can reduce the text? I tried to add HTML abbr, but it doesn’t work.
Best regards Paul.
Using custom formatting, you can check the length of your text, and if the text length is greater than a certain number, you can limit the length by using substring. For example, if your comment column is called "Comment", you could do something like this:
Html.Telerik().Grid(Model)
.Name("MyGrid")
.CellAction(cell =>
{
if (cell.Column.Title != null)
{
if (cell.Column.Title.Equals("Comment"))
{
if (cell.DataItem.Comment.Length > 25)
{
cell.Text = cell.DataItem.Comment.Substring(0, 25) + "...";
}
}
}
});
Update
You asked about showing the complete comment. I don't know of a simple way built into the telerik control, but you can do it using css. I am using css code from kollermedia.at, but there are lots of examples of css tooltips if you want a different style.
In your css, put something like this:
/* tooltip */
a:hover {background:#ffffff; text-decoration:none;} /*BG color is a must for IE6*/
a.tooltip span {display:none; padding:2px 3px; margin-left:8px; width:130px;}
a.tooltip:hover span{display:inline; position:absolute; background:#ffffff; border:1px solid #cccccc; color:#6c6c6c;}
Then change the line in your view to this:
cell.Text = "<a class=\"tooltip\" href=\"#\">" + cell.DataItem.Comment.Substring(0, 25) + "<span>" + cell.DataItem.Name + "</span></a>";
When you hover over the shortened text, the complete text is displayed in a tooltip.

TinyMCE editor fixed size with no scrollers?

At the moment I have this:
tinyMCE.init({
// General options
mode : "exact",
elements : "fkField, lkField, ukcField, khField",
theme : "advanced",
plugins : "table",
width : "300",
height: "185",
// Theme options
theme_advanced_buttons1 : "fontsizeselect, bold,italic,underline,bullist, cleanup, |,justifyleft,justifycenter,justifyright",
theme_advanced_buttons2 : "tablecontrols",
theme_advanced_buttons3 : "",
theme_advanced_buttons4 : "",
theme_advanced_toolbar_location : "bottom",
theme_advanced_toolbar_align : "center",
theme_advanced_resizing : false
});
This gives me a editor with the size of 300x185.
Now in this editor, I would like to do so you can only write until the editor is full. (without the scroller)
So you are unable to enter more text, and the scroller should not appear (disable scrolling)
Right now you can at the bottom of inside the editor just make new line and it will add the scroller <- which i do not want to happen
How can i do this? Is this unpossible? I have made research for some time now, but maybe it's just me searching wrong..
Thanks
add in a ccs file the following code
.mceContentBody{
overflow-y:hidden!important;
}
and add the path of css file in content_css attribut of tinymce
content_css : /path/to/css/file.ss
You will need to write an own plugin. Check the editor height on each Keystroke (you may use the built in tinymce event onKeyUp). If the heigth changes remove the last inserted code.
EDIT: Howto get the current editor iframe heigth
var currentfr=document.getElementById(editor.id + '_ifr');
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) { //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight + 26;
}
else if (currentfr.Document && currentfr.Document.body.scrollHeight) { //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
}
I got it to work by adding this to my extra tinyMCE CSS file:
IFRAME {overflow:hidden;}
Previously, the scrollbars were only off in Firefox. This fixes it for Chrome as well. However, it does add a gray bar the side of a scrollbar at the bottom, so I need to enlarge the height of my text editor.
for me it worked by just adding rules to a regular stylesheet, it wasn't needed to add a css file to content_css attribute (example is in scss)
.my-tinymce-container {
width: 200px;
.mce-edit-area {
height: 200px;
overflow-y: hidden;
}
}
A lot simpler and easy solution would be:
tinymce.init({
selector: '#container',
},
init_instance_callback: function (ed) {
tinymce.activeEditor.getBody().style.overflow = 'hidden'
},
});
Explanation:
In Init callback get the body for TinyMCE and change style as required.
In this case to remove scrollbar overflow = 'hidden'.

SIFR3 & jQuery for a styleswitcher script, need a last tip please! ;o)

I spent a lot of time trying to configure a styleswitcher script that replace my html background and css from one color to another, I got some texts using SIFR3, mainly h1, h2 tahs and h2 a: links...
My only problem is that when I'm switching, the flash text doesnt take the color change into consideration, I've tried to play with rollBack but I'm out of luck.
I found an interessant solution here :
function changeColor(hexValue) {
var css = '.sIFR-root { color: ' + hexValue + '; }';
for (var i = 0; i < sIFR.replacements['h1'].length; i++) {
sIFR.replacements['h1'][i].changeCSS(css);
}
for (var i = 0; i < sIFR.replacements['h2'].length; i++) {
sIFR.replacements['h2'][i].changeCSS(css);
}
}
// after switching stylesheet:
changeColor('#FF9900');
It works for h1, h2 but not for my h2 a: links...
Can you tell me how to adjust this?? It would be really really nice.
Right now when firing this function, my links just turn in their old html look with underline text decoration. Thanks !!
You need to pass in the new (or existing) styles for the a as well.

Resources