Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Right align p:inputNumber in a p:dataTable

I've coded a PrimeFaces (JSF / Java) p:dataTable that uses p:inputNumber for each cell. Everything works, but the table looks ragged due to the left-alignment of p:inputNumber's content. All of the formatting I've tried formats the control itself, not its content.

Is there any way to right-align the content of a p:inputNumber?

like image 293
Stuart Wilson Avatar asked Nov 21 '25 09:11

Stuart Wilson


1 Answers

If someone in 2020 or later is visiting this page:

For PrimeNG 10 the Angular ngStyle Syntax is needed for input style. Just do the following:

<p-inputNumber [(ngModel)]="0.00" [inputStyle]="{'text-align': 'right'}"></p-inputNumber>

Update 2023:

The above is still a possibility. But when using primeflex I like this solution better, using the already available 'text-right'-class:

<p-inputNumber [(ngModel)]="0.00" inputStyleClass="text-right"></p-inputNumber>
like image 123
J-Eibe Avatar answered Nov 24 '25 04:11

J-Eibe