Custom message button on the toolbar.

QuestionsCustom message button on the toolbar.
Montemaggiore Sebastian asked 9 years ago

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.

3 Answers
Abu Ghufran answered 9 years ago

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')

Montemaggiore Sebastian answered 9 years ago

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.

Abu Ghufran answered 9 years ago

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.

Your Answer

1 + 1 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?