Reputation: 43
I have a small problem that maybe you guys can help me. I want to add a button to the grid that changes value depending on the line ie:
onSelectRow: function(id)
{
jQuery('#organismos').jqGrid('navButtonAdd', '#pager1',{caption: "", buttonicon: "ui-icon-image", title: "AO",onClickButton: function() {window.open('Hierarquia/tree_objetivos.php?idorg=' + id, '_blank');
}
Problem is that it will keep adding buttons. And what I wanted was for him to change value so each time you select a row. Have googled and asked for help in the forum and nobody helped me jqgrid. Someone can help me?
Upvotes: 0
Views: 1010
Reputation: 24125
I would suggest adding button only once (after initializing the grid) and getting the selected row id from jqGrid options:
jQuery('#organismos').jqGrid('navButtonAdd', '#pager1', {
caption: '',
buttonicon: 'ui-icon-image',
title: 'AO',
onClickButton: function() {
var selectedRowId = jQuery('#organismos').jqGrid('getGridParam', 'selrow');
if (selectedRowId) {
window.open('Hierarquia/tree_objetivos.php?idorg=' + encodeURIComponent(selectedRowId), '_blank');
} else {
alert('You need to select a row first!');
}
}
});
Upvotes: 2