Set custom style in DynaFormRow

Community Driven Extensions Project
Post Reply
User avatar
vellgarath
Posts: 4
Joined: 03 Nov 2010, 10:59

19 Jun 2015, 10:45

Hi,

I was wondering if it would be possible to add the customization of DynaFormRow elements DynaFormControl and / or DynaFormLabel. I need to change the background of one cell (td tag) dynamically and I cannot use the tag styleClass because of it is a static style class and the background color depend of the data.

I tried extend and override the model (extend the AbstractDynaFormElement class for add a style attribute and make a customizable renderer of DynaForm and add this style tag to the td tag), but I don't know how I have to do it.

The only way that I found was introduce a div tag with the same padding that the td tag and set the td padding to 0px, but I have to add one div in each DynaFormControl.

Thanks for all and sorry for my english.

Regards.

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

21 Jun 2015, 14:10

To set styleClass dynamically, you can extend your data object. Simple add an attribute "styleClass" with getters / setters and reference it in pe:dynaFormControl with styleClass="#{data.styleClass}".
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

User avatar
vellgarath
Posts: 4
Joined: 03 Nov 2010, 10:59

21 Jun 2015, 22:12

Hi Oleg, yes, I knew this option, but I need to load the background color from a database and this color can be changed by the user... then, I would need the style attribute (not only de styleClass) because I cannot have a class for each color :)

it would be possible to have this option in the future or is there any way to dynamically load the background color?

Thanks for all.

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

22 Jun 2015, 12:23

Ok, I understood. You can create an issue in our issue tracker and I will add the "style" attribute to the pe:dynaFormControll in the next release. Theoretically, the logic is the same as for the "styleClass" attribute. You can search for "styleClass" in the code and extend these places with "style" too.

For now, maybe you can set the style attr. dynamically with JavaScript.

By the way, I also plan to add the responsive mode to the DynaForm. Probably als <p:dynaForm responsive="true" ..../>. In this case, the DIVs instead of Table will be rendered.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

User avatar
vellgarath
Posts: 4
Joined: 03 Nov 2010, 10:59

22 Jun 2015, 12:47

Ok, this is my first issue: https://github.com/primefaces-extension ... issues/344

I hope I have correctly opened the issue.

Thanks for all.

hwaastad
Posts: 56
Joined: 11 Oct 2010, 12:43

30 Jun 2015, 14:38

Oleg wrote:Ok, I understood. You can create an issue in our issue tracker and I will add the "style" attribute to the pe:dynaFormControll in the next release. Theoretically, the logic is the same as for the "styleClass" attribute. You can search for "styleClass" in the code and extend these places with "style" too.

For now, maybe you can set the style attr. dynamically with JavaScript.

By the way, I also plan to add the responsive mode to the DynaForm. Probably als <p:dynaForm responsive="true" ..../>. In this case, the DIVs instead of Table will be rendered.

Hi, I saw this one.

Will the responsive=true work reasonable together with the primefaces grid css styling?

br hw

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

03 Jul 2015, 12:26

I prefer Bootstrap. It is much powerfull. But if you have DIVs (responsive mode), you can set you custom style class in order to be able to use "primefaces grid css styling" or whatever else.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

hwaastad
Posts: 56
Joined: 11 Oct 2010, 12:43

03 Jul 2015, 20:48

Oleg wrote:I prefer Bootstrap. It is much powerfull. But if you have DIVs (responsive mode), you can set you custom style class in order to be able to use "primefaces grid css styling" or whatever else.
Sure,
good point.

Looking forward to having divs instead of table :-)

br hw

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests