2

私は何かを達成しようとしていますが、それが完全に可能かどうかはわかりません。

ASP.NET MVC を使用した Telerik MVC Grid があります。

グリッドのデフォルトのページング サイズは 10 ですが、ユーザーの解像度のサイズに基づいてページのサイズ (行数) を調整できるようにしたいと考えています。これは可能ですか?

ありがとう、

ポール

4

1 に答える 1

1

それは間違いなく可能です。

私は同じことを達成するソリューションを作成しました - ただし、独自のグリッドの適切な高さを取得するには、それをいじる必要があります (メニュー/ヘッダー/フッターなどを除く) 。

次の手順を実行してください。

まず、「onLoad」イベントを MVC グリッドに追加する必要があります。

    .ClientEvents(events =>events.OnLoad("onLoad"))

次に、$(document).ready() で「onLoad」を処理する Javascript イベントを作成します。

    function onLoad(e)
    {
        //Bread and Butter will go here.
    }

最後に - 最後のステップは、グリッドによって占有されていないスペースを計算し (Firebug が役立つ場合があります)、ほとんどのブラウザーで「数式」が機能するまでそれを調整することです。

   function onLoad(e)
    {
       //Gets the height of the Window. ($(window).height())
       //Subracts the height of any menus/headers/footers (in this case 275)
       //Then divide by our "magic number" which you will need to tinker with
       //to determine how the grid looks in different browsers. (in this case 28)

       var height = Math.floor(($(window).height()-275)/28);
       var grid = $("#YourGrid").data("tGrid");
       grid.pageSize = height;
    }   

方式 :

$(window).height() - [Occupied Space] / [Magic Number]

[Occupied Space] - Total CSS Height of all objects above the Grid.

[Magic Number]   - You will have to play with this one and try it out on 
                   different browsers until you get the expected results.

ウィンドウの高さに基づいて行数を自動的に調整する必要があります。

お役に立てれば!

于 2011-03-25T14:14:51.147 に答える