Hi,
I managed to come up with a code that can make flexigrid more "fluid", more specifically it can resize depending on the window size on page load, but now I would like to add the function to resize automatically when the size of the window changes without refreshing it.
This is what I have so far:
$(document).ready(function(){
var myWidth;
var myHeight;
var rowno;
if($(window).resize(function(e) {
// do something when window resizes
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
var rowno = Math.floor((myHeight - 96)/29)
}));
$("#flex1").flexigrid
(
{
url: 'post2.php',
dataType: 'json',
colModel : [
{display: 'ID', name : 'id', width : (myWidth*0.018), sortable : true, align: 'center', hide: false},
{display: 'URL', name : 'url', width : (myWidth*0.38), sortable : false, align: 'left'},
{display: 'File Name', name : 'filename', width : (myWidth*0.239), sortable : true, align: 'left'},
{display: 'Availability', name : 'availability', width : (myWidth*0.038), sortable : true, align: 'center'},
{display: 'State', name : 'state', width : (myWidth*0.029), sortable : true, align: 'center'},
{display: 'Total Size', name : 'totalsize', width : (myWidth*0.05), sortable : false, align: 'center'},
{display: 'Current Size', name : 'currentsize', width : (myWidth*0.05), sortable : false, align: 'center'},
{display: 'Procent', name : 'procent', width : (myWidth*0.04), sortable : true, align: 'center'},
{display: 'Log', width : (myWidth*0.018), sortable : false, align: 'center'},
],
buttons : [
{name: 'Add', bclass: 'add', onpress : test},
{name: 'Delete', bclass: 'delete', onpress : test},
{separator: true},
{name: 'Start', bclass: 'start', onpress : test},
{name: 'Stop', bclass: 'stop', onpress : test},
{separator: true},
{name: 'Select All', bclass : 'selectall', onpress : test},
{name: 'DeSelect All', bclass : 'deselectall', onpress : test},
{separator: true}
],
searchitems : [
{display: 'URL', name : 'url'},
{display: 'Filename', name : 'filename', isdefault: true}
],
sortname: "id",
sortorder: "asc",
usepager: true,
title: '',
useRp: false,
rp: rowno,
showTableToggleBtn: true,
height: (myHeight - 96)
}
);
});
Right now it throws me an error in jquery about an invalid argument, but I am pretty sure is syntax problem.
Thanks,
Cristian.