primefaces subtable styleClass - css

I have a p:subtable inside a datatable.
In my datatable I'm using rowStyleClass attribute to define row's colour. All the row is painted but not the Subtable
What should I do to paint the subtable aswell.
Even if subtable would have a styleClass attribute, I could specify it again for it, but as far as I know, it doesn't exists

if subtable also has the class 'ui-datatable' try to style it
.ui-datatable .ui-datatable {
background-color:none;
}

Related

Angular / CSS style change width of row items

I am conceiving a horizontal bar containing items.
They must all be of same width, having the same spacing between them.
They can expand as much as they want vertically (
stackblitz here
Problem:
How to automatically set the width of the row elements? Here I simply put a value that looks good: width:200px.
I want them to have a width dependent on the number of element per row.
What I tried:
Using elementRef in Horizontile (component holding the individual tiles, displaying with *ngFor) to get the width of this element:
currentWidth:number;
constructor(private el:ElementRef) {}
ngAfterViewInit(): void {
this.currentWidth=this.el.nativeElement.offsetWidth;}
it returns 5. (??) Using .width returns nothing. Also this is not recommended, I'd like another solution, less coupling.
I noticed I can make use of width:inherit; in the css of the individual tile component, which allows me to set the style from the horizontal list component.
<app-tile [style.width.px]="0.9*currentWidth/nDisplayedTiles" [tile]="item"></app-tile>
As the currentWidth value is zero, of course it doesn't work;
I tried setting it in % but the inherits css tag keeps the %, which is not the intended effect.
Why is the app-tile styling not cared about if inherits is not set?
I tried using ViewEncapsulation but it had no effect either.
This looks like a trivial matter though: did I just miss something?
You can use the offsetParent (link) width and create a method to return the value on each of the cells and call it in your [style.width.px], something like the following will work.
The HTMLElement.offsetParent read-only property returns a reference to the element which is the closest (nearest in the containment hierarchy) positioned ancestor element.
stackblitz
ngAfterViewInit(): void {
//added this as the compiler was throwing ExpressionChangedAfterItHasBeenCheckedError
setTimeout(() => {
this.currentWidth=this.el.nativeElement.offsetParent.clientWidth;
});
}
getWidth(): number{
let width:number = 0;
//you may need to change this value to better display the cells
let multiplier = 0.7;
width = (this.currentWidth * multiplier) / this.ndisplayTiles;
width = Math.round(width);
return width;
}
<app-tile [class]="'layout-tile'" [tile]="item" [style.width.px]="getWidth()">
</app-tile>

Using in-line styles with JavaFX ScrollPane

I'm trying to style a ScrollPane using the inline setStyle() method, but it have no effect on the ScrollPane colors. I've searched SO for examples but none of them were in-line.
sp = new ScrollPane();
String css;
css = ".scroll-pane {-fx-background-color: black;}\n"+
".scroll-pane > .corner {\n" +
" -fx-background-color: black;\n"+
"}\n"+
".scroll-bar:horizontal.track,\n"+
".scroll-bar:vertical.track\n"+
"{\n"+
" -fx-background-color: black;\n"+
" -fx-border-color: black;\n"+
" -fx-background-radius: 0em;\n"+
"}";
System.out.println(css);
sp.setStyle(css);
There is any error on the inline css String?
You can't use selectors in inline styles. You just provide rules that are applied directly to the node (sp in this case). So there is no way to apply an inline style to child nodes, or apply it to pseudoclasses in the way you are trying here.
You could, in theory, do what you are trying to do here with something like
sp.setStyle("-fx-background-color: black;");
sp.lookup(".corner").setStyle("-fx-background-color: black;");
For the pseudoclasses :horizontal and :vertical you would need to register a listener with sp.getPseudoClassStates(). In that listener, you would do a lookup for ".track" and set the style for the track depending on whether or not the set of pseudoclass states contained horizontal and/or vertical.
Obviously this gets prohibitively complex and unmaintainable quickly. You should use an external CSS file for this.

How to change the background color of the focussed table row

So I've a method that focuses the table row based on the row index. However, the default background color of the focused row is grey, which is not easily visible. I want to change this color to steelblue. Please suggest how to do it. Below is my code for the method.
public static void focusTableRow(TableView table, int rowIndex){
table.requestFocus();
table.getSelectionModel().select(rowIndex);
table.getFocusModel().focus(rowIndex);
table.scrollTo(rowIndex);
}
To style the rows, Add CSS in the external CSS file :
.table-row-cell:selected {
-fx-background: steelblue;
}
Update:
Save the content of this style in a rowStyles.css. then you have to add the URL for the rowStyles.css style sheet to the scene:
scene.getStylesheets().add(getClass().getResource("rowStyles.css").toExternalForm());

Is there a different way to style table rows in javafx

I currently am using a custom cell factory in Javafx to style cells/rows of my table view with css. This is working successfully and exactly how I need it to. I was wondering if there was another way to style the rows of a table view.
I want to style the entire row with css dynamically instead of cell by cell. Some of the rows will be different colors, etc. Font fill, background color, font size, etc.. nothing fancy.
You can use a rowFactory on the table which generates rows and manipulates either the style class of the row or a pseudoclass attached to the row. Then use an external style sheet to apply the styles.
e.g.
PseudoClass foo = PseudoClass.getPseudoClass("foo");
table.setRowFactory(tv -> {
TableRow<MyDataType> row = new TableRow<>();
row.itemProperty().addListener((obs, oldItem, newItem) -> {
if (/* some condition on newItem */) {
row.pseudoClassStateChanged(foo, true);
} else {
row.pseudoClassStateChanged(foo, false);
}
});
return row ;
});
and then
.table-row-cell {
/* your regular style settings here */
}
.table-row-cell:foo {
/* your specific style for when foo is set here */
}

How to change style class of td in table using SAPUI5

In SAPUI5, there is no APIs to change anything the table cell itself.
The following code is to modify the style of the cell and control in the cell in formatter, but both of them adds style class to the control, not td.
Could anyone indicate how to change td style in a table?
editableFormatter: function(v, control) {
if(sap.ui.getCore().byId("btnEdit").getText()==="Edit") {
control.getParent().getCells()[2].addStyleClass('readonly');
control.addStyleClass('readonly');
}
}
I dont think you can apply readOnly using CSS. You need to use JQuery or Javascript to make the field readOnly.
Example:
document.getElementById("id").setAttribute("readonly", "true");
A table cell (<TD>) is not a SAPUI5 control, so getting the SAPUI5 parent from a Text will return the bound item (or HTML <TR>)
To get to the actual TD DOM object, first get the SAPUI control, and then its DOM parent using its jQuery object:
var td = control.getParent().getCells()[2].$().parent();
...and to set a css style to this TD DOM object, use standard Javascript:
td.className = td.className + " myCSSStyle";
PS note the space before the style classname
Definitely we need to manipulate DOM after document is ready,
I managed to get the data array and get cells using jquery:
for(var i = 0, j = parameters.length; i < j; i++) {
$('#'+table.getId()+'-rows-row'+i+'-col'+idx).addClass('readonly');
}
It works, but I wonder if there are better solutions.
Best Regards,
Mingquan

Resources