0

フレキシグリッドをより「流動的」にすることができるコードを思いつくことができました。より具体的には、ページの読み込み時にウィンドウのサイズに応じてサイズを変更できますが、ウィンドウのサイズが変更されたときに自動的にサイズを変更する機能を追加したいと思いますリフレッシュせずに。

これは私がこれまでに持っているものです:

$(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)
            }
            );   
});

現在、無効な引数についてjqueryでエラーが発生していますが、構文の問題であると確信しています。

ありがとう、

クリスチャン。

4

2 に答える 2

1

任意の要素の高さのサイズを確認し、それを合計すると、約 120 ピクセルになります。したがって、次のようなこと (flexigrid config object プロパティ) を行えば、問題ありません:

$("#tabla").flexigrid({
   ...,
   width:'auto',
   height:$("#container").innerHeight()-120
});

于 2012-12-17T18:24:54.240 に答える
0

pxやemの代わりにサイズに%を使用する方が良いです。このような大きなスクリプトがなくても問題なく動作します。

**編集**

それでも実行したい場合は、1秒ごとにブラウザのwindow.heightとwidthのサイズをwindow.widthでチェックするsettimeout関数を指定します:)

あなたがこれで成功した場合、私はあなたのスクリプトをコピーする最初の人です私は同じものを探しています。。しかし、%に慣れました

于 2010-10-31T18:07:47.113 に答える