Hello Abu. I use a custom toolbar buttom. I want to show a message when no row is selected, and in that case i don't wanto to performa any action.
how do i do this?.
Here´s my code:
jQuery(document).ready(function(){
jQuery('#clientes').jqGrid('navButtonAdd', '#clientes_pager',
{
'caption' : '',
'buttonicon' : 'ui-icon-suitcase',
'title' : 'Efectuar una reserva',
'onClickButton': function()
{
// for all ids
// var allRowsOnCurrentPage = $('#list1').jqGrid('getDataIDs');
// for selected rows
var selectedRows = selectedRows = jQuery('#clientes').jqGrid('getGridParam','selarrrow');
window.open("proceso_reserva_grilla_destinos.php?c_id="+selectedRows,'_self')
},
'position': 'last'
});
Non parameter allow custom message whe no record is selected.
Thanks Abu.
You can use selectedRows.length. 'selarrrow' return array of selected row ids.
var selectedRows = jQuery('#clientes').jqGrid('getGridParam','selarrrow');
// e.g. check
if (selectedRows.length == 0) { alert('Please select some row'); return; }
window.open("proceso_reserva_grilla_destinos.php?c_id="+selectedRows,'_self')
Thanks Abu. I did something similar but i couldn´t give the message the same appearence of the jquery theme that i´am using. How can i implement the same message that the grid implement when the user want to edit a record and did no select a row?.
Thanks again.
Here you go…
if (selectedRows.length == 0)
{
jQuery.jgrid.info_dialog(jQuery.jgrid.errors.errcap,
'<div class="ui-state-error">'+jQuery.jgrid.nav.alerttext+'</div>',
jQuery.jgrid.edit.bClose,{buttonalign:'right'});
return;
}
You can replace " jQuery.jgrid.nav.alerttext " with your string.