Q:

how to center jqGrid popup modal window? 

Possible Duplicate:
jqGrid Reposition Delete Confirmation Box 

I've started using jqGrid for few days and everything is working cool.so far so good. 
What borders me is that when you click on edit button in the NavGrid without selecting a row, it shows a centered modal popup notifying of no row being selected. 
But when you click on add or edit(with selected row) it shows a modal at the left side of the grid. Not centered at all.   
I'll like to find a way to center it. 
How is that done?  or it can not be done out of the box?   
thanks for reading this

A:

It seems to me, that the easiest way to do this is to change the dialog position inside of the beforeShowForm event:
var grid = $("#list");    
grid.jqGrid('navGrid','#pager',
            {add:false,del:false,search:false,refresh:false},
            { beforeShowForm: function(form) {
                  // "editmodlist"
                  var dlgDiv = $("#editmod" + grid[0].id);
                  var parentDiv = dlgDiv.parent(); // div#gbox_list
                  var dlgWidth = dlgDiv.width();
                  var parentWidth = parentDiv.width();
                  var dlgHeight = dlgDiv.height();
                  var parentHeight = parentDiv.height();
                  // TODO: change parentWidth and parentHeight in case of the grid
                  //       is larger as the browser window
                  dlgDiv[0].style.top = Math.round((parentHeight-dlgHeight)/2) + "px";
                  dlgDiv[0].style.left = Math.round((parentWidth-dlgWidth)/2) + "px";
              }
            });

You can see live the example here. 

A:

For some reason Oleg's code, as listed, wasn't completely working for me (though I wouldn't have ever gotten this far without it). 
Two issues:
1.)  If you just paste in what's in that answer, you'll move your edit modal, but not your add modal.   I only have an add modal, so that was confusing for a while.   You basically just double the code (see below). 
2.)  The code Oleg's written was adding the averaged top and left relative to the entire page rather than the parent div.   I'm sure I'm missing something obvious (or perhaps that's what the TODO is about?),  but this worked for me...

Note: I edited to factor the function out to reuse in add and edit modals and haven't actually tested the changes.  If this doesn't work, see the previous revision. 

var grid = $("#list");    

function centerDialog(form)  {
  //alert('adding' + "#editmod" + grdNames[0].id);
  var dlgDiv = $("#editmod" + grdNames[0].id);
  var parentDiv = dlgDiv.parent(); // div#gbox_list
  var dlgWidth = dlgDiv.width();
  var parentWidth = parentDiv.width();
  var dlgHeight = dlgDiv.height();
  var parentHeight = parentDiv.height();

  // Grabbed jQuery for grabbing offsets from here:
  //https://stackoverflow.com/questions/3170902/select-text-and-then-calculate-its-distance-from-top-with-javascript
  var parentTop = parentDiv.offset().top;
  var parentLeft = parentDiv.offset().left;

  // HINT: change parentWidth and parentHeight in case of the grid
  //       is larger as the browser window
  dlgDiv[0].style.top  = Math.round( 
    parentTop  + (parentHeight-dlgHeight)/2  
  ) + "px";

  dlgDiv[0].style.left = Math.round( 
    parentLeft + (parentWidth-dlgWidth  )/2 
  )  + "px";
}

// Now it's easy to reuse that function to center stuff. 
grid.jqGrid(
  'navGrid','#pager',
  {add:false,del:false,search:false,refresh:false},
  { beforeShowForm: centerDialog }, // edit modal
  { beforeShowForm: centerDialog }  // add modal
);

