CodeNinja
CodeNinja

Reputation: 3278

Jquery Dialog Limit Height

I am using a jquery dialog which opens up on button click.

There is a grid view within the jquery dialog.

Sometimes there are a lot of rows within the gridview , in which case the dialog stretches from the top of the screen to the bottom.

I would like to limit the size of the dialog and add a scroll bar.

I tried a combination of all the following settings as shown below but it still doesnt work .

 $(function () {
        $("#Div1").dialog({
                    height: 140,
                    modal: true
             autoOpen: false,
            modal: true,
            MinHeight: '20',
            maxHeight: '400',
            width: '700',
            scroll: true,
            resizable: false,
            create: function () {
                $(this).css("maxHeight", 400);
            }
        });
    });

Does anyone have a solution ?

Upvotes: 0

Views: 290

Answers (1)

dan_vitch
dan_vitch

Reputation: 4559

EDIT

you can retrieve height of object using height and check it against a variable

var maxHeight = 200;
var currentHeight = $('#gridviewContainer').height(); 
var desiredHeight = (currentHeight  < maxHeight ) ? currentHeight : maxHeight;
.dialog({
    height: desiredHeight,
    scrollable: true
});

Upvotes: 1

Related Questions