Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
How to, well behaved, max width 100% jqGrid
28/04/2014
13:15
Avatar
Dafydd
New Member
Members
Forum Posts: 1
Member Since:
28/04/2014
sp_UserOfflineSmall Offline

Hi,

Thought I would share how I got jqGrid to behave in the way I wanted as the container/page resized in width.

I wanted to preserve the column model, refrain from expanding past the container/page width and forcing the horizontal scroll bar to kick in, at the same time not to strech if there are not enough columns to fit the container.

The data I was displaying could have any number of columns in it, of varying sizses, and the container/page can also vary in width based on user prefrences/screen size or browser window.

Fist thing to do is diasble  ShrinkToFit="false"

Then add some css rules to your page, overriding the ui rules: -

/*stops the grid expanding past the bounds of the container, but allows it to shrink below when there are too few columns*/

.ui-jqgrid-htable,
.ui-jqgrid-btable,
.ui-jqgrid-pager,
.ui-jqgrid-view,
.ui-jqgrid-bdiv,
.ui-jqgrid-hdiv,
.ui-jqgrid-hbox,
.ui-jqgrid { max-width: 100% !important; }

/*this fixes a bug when you fully scroll to the right when you have many columns in the grid*/

.ui-jqgrid-htable { padding-right: 17px; }
.ui-jqgrid-hbox { padding-right: 0px !important; }

If you want small grids (low column count) to expand and use the full width of the container, you can add a width rule: -

.ui-jqgrid-htable,
.ui-jqgrid-btable,
.ui-jqgrid-pager,
.ui-jqgrid-view,
.ui-jqgrid-bdiv,
.ui-jqgrid-hdiv,
.ui-jqgrid-hbox,
.ui-jqgrid { max-width: 100% !important; width:100% !important; }

Hope this helps someone 🙂

03/05/2014
10:07
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

I have not tested this, but I would say - Thank you very much for sharing your solution.

Regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
39 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information