Q:

Alert message using viewModal function in Jqgrid

I'm trying to implement a simple alert message using jqgrid and a custom nav. buttom.
All I wanted to do is when the button is clicked, it shows an alert if no row is selected(just like the default buttons that already work).
here's the code:
  onClickButton : function () { 

                    var line = $('#grid-list').jqGrid('getGridParam', 'selrow');
                    var grid = $('#grid-list');
                    var grid_id = grid[0].id;

                    if ( !line ) {
                        $.jgrid.viewModal("#alertmod",{gbox:"#gbox_"+grid_id,jqm:true});
                        $("#jqg_alrt").focus();
                    }
                    else {

Any suggestion??
thanks a lot.

A:

The main error in your code is the usage of "#alertmod" instead of "#alertmod_grid-list" where grid-list is the id of the grid.
The demo demonstrate the fixed code. It uses the following code of onClickButton callback:
onClickButton: function () {
    var idSelector = "#alertmod_" + this.p.id;
    $.jgrid.viewModal(idSelector, {
        gbox: "#gbox_" + $.jgrid.jqID(this.p.id),
        jqm: true
    });
    $(idSelector).position({
        of: "#" + $.jgrid.jqID(this.p.id),
        at: "center",
        my: "center"
    });
    $(idSelector).find(".ui-jqdialog-titlebar-close").focus();
}

In the above code I changed position of the Warning additionally and changed the focus so that one can close the box by pressing of Enter key (like described in the answer).

