0

i am trying to center the alertmod dialog on jqgrid. I have tried the answer by Oleg but did not work for me.

jqGrid warning dialog

The alert happens when a button on pager is pressed (like delete) and a row is not selected.

I have this function setup for the delete, edit, etc dialogs and works fine

 jQuery.fn.center = function () {
                this.css("position", "absolute");
                this.css("top", ($(window).height() - this.height()) / 2 + $(window).scrollTop() + "px");
                this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px");
                return this;
            }

I just cant get it to work for this error dialog

This is how i call it on the other dialogs like edit, delete, etc

afterShowForm: function (form) {
                        form.closest('div.ui-jqdialog').center();
                    }
Community
  • 1
  • 1
BigDX
  • 3,519
  • 5
  • 38
  • 52

1 Answers1

0

First of all you try to center alert inside of afterShowForm callback of form editing, but editGridRow method will be not called in case if no row is selected. Instead of that navGrid just calls $.jgrid.viewModal instead. jqGrid allows you to control position and the size of alert dialog using the following options of navGrid: alertwidth (default value is 200), alertheight (default value is "auto"), alerttop, alertleft, alertzIndex.

Alternatively you can replace or "subclass" $.jgrid.showModal or $.jgrid.viewModal methods to be able to center the dialog after it will be shown. See the answer or this one for more details.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798