Can't wrap the contents of ag-grid Row - html

I'm trying to wrap contents of a row of ag-grid into multiple lines but I can't get the contents to display over multiple lines. The data for rows is provided dynamically at the time of certain condition check.
I have tried using the white-space:normal property but it didn't do anything.
I also tried wrap-text but it is not a valid property.
Here's my code for reference.
component.ts
columnDefs = [
{headerName: 'S.No.', field : 'SNo'},
{headerName: 'Error Description', field: 'Error_Description', autoHeight: true},
]
rowData = []
provide data to rows
for(let i = 0; i<this.validationErrors.length;i++){
let errorObj={};
errorObj["SNo"]=i+1;
errorObj["Error_Description"]=this.validationErrors[i];
this.rowData=[...this.rowData, errorObj]
}
And here is a snapshot of the display
index.html
As you can see in the image, the AZAAAAAA.... part is overflowing. The following is the css that is applied to the cell implicitly.
style.css
.ag-cell {
display: inline-block;
overflow: hidden;
position: absolute;
text-overflow: initial;
white-space: inherit;
}
If I try to alter the text-overflow property to initial or if I try to change the white-space to normal, it clips the entire AZAAA... part.
How do I resolve this?
Note: I'm not using any of the APIs to handle rows or columns. I have just defined 2 arrays and bound them to the html as follows:
<ag-grid-angular [hidden]="isValid" class="ag-theme-balham" [rowData]="rowData" [columnDefs]="columnDefs">
<!-- Show table -->
</ag-grid-angular>

Related

Ag-grid column menu: display overflow text

By default Ag-grid sets a fixed column menu width. Their documentation has an example of setting the column menu width to a different fixed value. The issue with this approach is that every column will have the same menu width.
Is there a way to dynamically set the column menu width based upon the column's filter list values? The following has no effect:
.ag-set-filter-list {
width: auto;
}
Similarly word wrapping could also solve this issue, but is also not working:
.ag-set-filter-list {
overflow-wrap: break-word;
}
I also tried using the postPopup callback to adjust styling after rendering, with no luck:
created() {
this.postProcessPopup = (params) => {
if (params.type !== 'columnMenu') {
return;
}
params.ePopup.style.overflowWrap = "break-word";
params.ePopup.style.width = "auto";
}
}
Digging into Ag-grid's filter list styling more, I realized that the filter items are absolutely positioned and use top values for placement. This made it difficult to wrap filter values without having them collide with each other.
I contacted Ag-grid support and they confirmed that dynamic filter list widths are not supported. They did mention their tooltips feature though, which works for my use case.
I modified that example in two ways:
Only show tooltips for filter list values that are longer and will be cut off by the edge of the filter menu.
Only show tooltips for values in the filter list, not for rows in the grid.
Here's my version of a custom tooltip with the above modifications:
export class GridColumnFilterTooltip {
init(params) {
const FILTER_VALUE_CHARACTER_LIMIT = 28;
this.tooltip = document.createElement("div");
if (
params.location === "setFilterValue" &&
params.value.length > FILTER_VALUE_CHARACTER_LIMIT
) {
this.tooltip.classList.add("grid-column-filter-tooltip");
this.tooltip.innerHTML = params.value;
}
}
getGui() {
return this.tooltip;
}
}

Increase the height of Filter List AG Grid Set Filter

Currently I am using Ag Grid v27.3.0, and contents inside filter list in Set Filter not being displayed correctly as shown in the below image. Data is not getting wrapped correctly.
Below is what i have tried, but of no use.
Am i missing anything here?
:host ::ng-deep .ag-set-filter-item
{
height: max-content;
}
It cannot be dynamic but you can set the height with the following config.
{ field: 'athlete', filter: true, filterParams: {
cellHeight: 35
} },
https://plnkr.co/edit/OOIbFw17EMxJWY72?open=app%2Fapp.component.ts

Getting "natural" display type for HTML elements?

I have a a web page where various fields are shown or hidden by toggling between "display:block" and "display:none". However, I added some extra stuff to the page and discovered that I needed to special-case several tags: TD needs to use "display:table-cell:, TR needs to use "display:table-row", and so on...
Is there any general off-the-shelf solution to this (i.e. look up the "natural" display type based on the tag name) or am I stuck with creating a JS object by hand which lists tag names and the corresponding display types?
You can apply revert to display property to set the element to it's original value and get the original value by Javascript.
const getOriginalDisplayProperty = (elem) => {
const modifiedDisplayProperty = getDisplayProperty(elem); //store modified display property
elem.style.display = "revert"; //revert to original display property
setTimeout(() => {
elem.style.display = modifiedDisplayProperty; // Again set original display property
}, 0);
return getDisplayProperty(elem);
};
const getDisplayProperty = (elem) =>
window.getComputedStyle(elem, null).display;
getOriginalDisplayProperty(document.querySelector(".test"));
getOriginalDisplayProperty(document.querySelector(".test-span"));
div {
display: inline;
}
span {
display: flex;
}
<div class="test"></div>
<span class="test-span"></span>

How to custom row when I create row has checkbox in ng2-smart-table?

I want when I create new row, In Status columns is checkbox. In Image is Input text
I can not provide you a full sample code right now but you should define a column for your checkbox. Provide a boolean value for that column. Don't forget to add
'type: custom'
It renders the Component you provide. I used a component named MyCheckboxComponent
<nb-checkbox [ngModel]="selected"></nb-checkbox>
nb-checkbox is in nebular library.
settings = {
columns: {
checkBox: {
type: 'custom',
filter: false,
width: '10px',
renderComponent: MyCheckboxComponent
}
}
}

CSS properties for general 'Formatters' in a Google Visualization Table

Google visualization API's include 'Formatters' which allow you to use things like colored text and arrows representing qualities of data. More information on formatters can be found here.
Now, when I edit the CSS values of the table, or use configurtion options (found here), tables that use fomatters seem to have trouble displaying certain CSS properties i.e, width of cells and text size. An example I've noticed where this is the case when the entire tables text is a smaller than default font, and a row is selected. That row which was selected will revert back to a 10pt Arial font when deselected.
Although this specific instance is annoying, I am curious about ALL formatter css properties and their class names. There is no information, to my knowledge, on the Google developer site.
These are my class names:
'headerRow': 'header-cells',
'tableRow': '.even-background all-cells',
'oddTableRow': 'odd-background all-cells',
'selectedTableRow': 'all-cells',
'hoverevenTableRow': '',
'hoveroddrTableRow': '',
'headerCell': 'header-cells white bold darkgreen-background',
'tableCell': 'all-cells'
};
These are the formatters being used.
var changecolor = new google.visualization.ColorFormat();
changecolor.addRange(null, 0, 'red', 'none');
changecolor.addRange(0.000001, null, 'green', 'none');
changecolor.format(dt, 1); // Apply formatter to second column
var parens = new google.visualization.NumberFormat({
prefix: "$",
negativeParens: true
});
parens.format(dt, 1); // Apply formatter to second column
var arrow = new google.visualization.ArrowFormat();
arrow.format(dt, 1); // Apply formatter to second column
var FormatAll = new google.visualization.NumberFormat({
prefix: "$",
pattern: '#.00##'
});
Style properties:
<style>
.all-cells {
border: 0px;
border-collapse: collapse;
font-size: 9px;
padding-right: 0;
}
.header-cells {
border: 0px;
border-collapse: collapse;
font-size: 9px;
padding-right: 0;
color: white;
font-weight: bold;
}
.darkgreen-background {
background-color: #0B3B0B;
}
.odd-background {
background-color: #E6F8E0;
}
.even-background {
background-color: #FFF5E3;
}
.bold {
font-weight: bold
}
.White {
fontcolor: white;
}
</style>
JS fiddle script in action
If you notice, when a cell is selected, the font size changes. This only happens when the google.visualization.ArrowFormat is applied.
I'd like to get rid of the boarder of the table, but that is not affected by classname or class properties (refer to the fiddle),
There is also a conflict with the parens.format and google.visualization.NumberFormat. Decimals places do not display with parentheses.
Not directly shown in code or fiddle: cell width properties become offset with cells that have formatters applied to them.
There are a couple things going on here. First, the ArrowFormat overrides all other classes placed on a cell, so those cells do not have the all-cells class. This is fine, as long as the <tr> has the all-cells class. The <tr>'s lose the all-cells class when you deselect them, because all-cells is part of both the even/odd row and selected row classes (and deselecting a row removes whatever classes you put on it.
If the reason you put all-cells as the selected row class is because you don't want the style from the default class, I suggest changing the class to something that has no styles associated with it, like this:
'selectedTableRow': 'noStyle'
Also, on a side note, you have a typo in the even row classes: there should not be a . before even-background:
'tableRow': 'even-background all-cells'
see it working here: http://jsfiddle.net/asgallant/1q8yk4f5/3/