Home › Forums › Guriddo jqGrid JS › Discussion › is it possible to have 100% width
Insted of defining width in pixels, is that possible to provide width in percent so it can fit on size of resolution?
Hello,
Check this form.
If you enclose the grid in div or other element
then
var gwdth = $(divelement).width();
$(…).jqGrid({
…
width: gwidth,
});
Then you can use setGridWidth method when the element resizes.
Regards
Tony
please Tony, can you explain more or give a live example!!
It is possible to use the entry width of grid as percentage, but not
columns. See my example aboveexample. Percentage have
sence only if you have parent element to wich you can set percent. You can use the javascript onresize event fort this purpose.
Which file do I have to add that piece of code to and where!!!. Sorry but am not getting it well.
Hi, Tony!
I've tried to set the grid width to the parent div element width – exactly
as you've proposed:
outerwidth = $(“#outer”).width()
$(“#testreport”).jqGrid({
width: outerwidth;
But it doesn't seem to work for me ( at least with FF 3.0.3 – I could not
check it with other browsers / versions ). The grid still goes way beyound
the right border
Does the outer div have any width?
Yes, it has:
#outer {
Hello
Try with:
#outher {
….
width : 500px
}
Width 95% means 95% from parent element
Tried to do it your way:
width: 500px;
No luck though – the grid still get wider then the container div.
Thanks.
If this does not help we can use another approach.
After creating a grid
outerwidth = $(”#outer”).width();
(“#mygrid”).jqGrid({
}).setGridWidth(outerwidth);
This one worked.
Thanks a lot!!!
I'm using the following method with the jquery “dimensions” plugin:
$(window).bind('resize', function() {jQuery(”#s1list”).setGridWidth($(window).width());});
In firefox its fine, but in IE 7 the horizontal scroll is all messed up and it shows a vertical scroll even with height: 100% after resizing. Any input on this?
Thanks!
Try to set not $(window).width(), but $(window).width()-5 or
something else
Hello tony,
Already tried that, no success.
From what i understand, in IE7 a vertical and horizontal scroll is added, but without purpose because i can see all the fields (screenshot below).
I have shrinkToFit: true.
You can set
shrinkToFit: true,forceFit: true
this gets rid of the horizontal scroll-bar.
Note that this is not perfect for loads of columns since there is no horizontal scroll-bar at all.
I hope this helps,
Sven
Stay connected with us in your favorite flavor!
Copyright 2014 TriRand LtdAll Rights ReservedRSS