JqGrid warning dialog

I have some custom buttons on the jqGrid toolbar. One of them depends on the selected line, as well as built-in edit and delete buttons. When a user clicks on it without any selected row, I want the user to be presented with the same warning dialog that is presented using the built-in Edit or Delete buttons. That is, I want to reuse the dialog that the grid uses, which says:

Caution Select row

Any idea where the grid displays a warning?

Thanks Scott

+4
source share
3 answers

I think the code might look like this

var alertIDs = {themodal: 'alertmod', modalhead: 'alerthd', modalcontent: 'alertcnt'}; $.jgrid.viewModal("#" + alertIDs.themodal, {gbox: "#gbox_" + $.jgrid.jqID(this.p.id), jqm: true}); $("#jqg_alrt").focus(); 

where this.p.id (or $.jgrid.jqID(this.p.id) ) can be replaced with the grid identifier. To be more confident that the alert work that I recommend you is recommended to use a longer code

 var alertIDs = {themodal:'alertmod',modalhead:'alerthd',modalcontent:'alertcnt'}; if ($("#"+alertIDs.themodal).html() === null) { $.jgrid.createModal(alertIDs,"<div>"+$.jgrid.nav.alerttext+ "</div><span tabindex='0'><span tabindex='-1' id='jqg_alrt'></span></span>", {gbox:"#gbox_"+$.jgrid.jqID(this.p.id),jqModal:true,drag:true,resize:true, caption:$.jgrid.nav.alertcap, top:100,left:100,width:200,height: 'auto',closeOnEscape:true, zIndex: null},"","",true); } $.jgrid.viewModal("#"+alertIDs.themodal, {gbox:"#gbox_"+$.jgrid.jqID(this.p.id),jqm:true}); $("#jqg_alrt").focus(); 

Demo demonstrates the code. It displays a message

enter image description here

every time you click the "Click me!" .

UPDATED: The answer contains information on how to use the above dialog in a free jqGrid . It describes many options. The simplest version contains only one simple call to this.modalAlert(); . It displays the same warning dialog that displays the jqGrid's internal screen.

+7
source

I just tried Oleg below solution and it does not work for me.
After debugging, I realized that $("#"+alertIDs.themodal).html() was "undefined" for me, so the case suggested by Oleg did not work properly.

I changed this:

 if ($("#"+alertIDs.themodal).html() === null) { 

in it:

 if ($("#"+alertIDs.themodal).html() === null || $("#"+alertIDs.themodal).html() === undefined) { 

and now it works fine.

+2
source
 $.jgrid.info_dialog.call(this, "Warning", // dialog title "Please, select row!" // text inside of dialog ); 

It worked for me!

-1
source

All Articles