Container responsive sizing

servicetrout
Tera Expert

I built a table in a record producer with a series of containers and fields like this where C1 (2 x 2) means Container 1   2 variables, first one side then the other.

[C1 (2x2)     [C2 (1x1)]         [c3 2x2     [c4 2x2] [c5 2x2 ]   ] ] ]

My issue is that the one field in container C2 take up 50% of the screen, while the other 4 fields   [c3 2x2     [c4 2x2] [c5 2x2 ]   ] ]   split the other 50%.

That is, it looks like this:

[ Field1                                                                                                 ]   [Field2   Field3] [Field4   Field5]

I would like it to be more like this:

[ Field1                         ]   [     Field2     Field3     ] [     Field4     Field5     ]

I tried changing the field size of both the container and field in a client load script using:

    g_form.getControl('c2Label').style.width = '80px';

    g_form.getControl('c2Label').style.height = '10px';

This does change the heights, but not the width.   Is there a way to set the width of everything in container C2 to just 25% of the screen width?

Or, any other options will be considered.

-G

1 ACCEPTED SOLUTION

sifynm
Tera Expert

Dear Mr. Glenn Strout,



                  Here is a link I found where they have mentioned "g_form.getControl('variable_name').setAttribute('style', 'width: 123px !important');". g_form.getControl not working in Helsinki . Here is also a link where it lists "Supported client side APIs with g_form class" link https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/build/service-portal/concept/uns...   . Please check!


View solution in original post

4 REPLIES 4

Rajesh Mushke
Mega Sage
Mega Sage

Hello servicetrout



check out mark.stanger SNCGURU article: » How to set up Field Styles for Service Catalog Variables in Service-now.com



Refer :



I think the below thread will help you


4 fields in 1 row - Catalog Item



ServiceNow KB: Determining if you are using the correct container variable (KB0539982)



Please mark your question as answered if it resolves your issue




Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

The code I provided was from the first link you provided.   However, I could not get it to work   when trying to set the field width.   Worked fine for the height though.



I already have 6 fields on a line, so the second link doesn't provide any guidance on sizing the fields.



Thank you for the input, though.


sifynm
Tera Expert

Dear Mr. Glenn Strout,



                  Here is a link I found where they have mentioned "g_form.getControl('variable_name').setAttribute('style', 'width: 123px !important');". g_form.getControl not working in Helsinki . Here is also a link where it lists "Supported client side APIs with g_form class" link https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/build/service-portal/concept/uns...   . Please check!


Bam - that works !   Nice.


Not responsive design, but it gets me a work around.



Thank you for finding this!