If a column in the grid meets a condition (at any time), I would like to hide/disable a few custom buttons in the grid header. is there an [“add_option”] that can read custom header buttons. Or is there and easier way to do this?
//////////////////////////
// DRAG AND DROP BUTTON //
//////////////////////////
var unit = “<?php echo $uid ?>”;
var job = “<?php echo $jid ?>”;
setTimeout(()=>{
jQuery(‘#<?php echo $g->id?>’).jqGrid(‘navButtonAdd’, ‘#<?php echo $g->id?>_pager’,
{
‘caption’ : ‘Drag and Drop’,
‘buttonicon’ : ‘ui-icon-arrow-4’,
‘onClickButton’ : function()
{
$(document).ready(function () {
window.location.href = “assets/equipment/unit_eq_dd.php?unit=” + unit + “&job=” + job;
});
},
‘position’: ‘last’
});
},10);
Thanks,
Tim
Closest demo code is http://jqgrid/dev/demos/editing/column-access.phps
Line 39, 198
It will disable certain buttons if the select row gender’s column is of certain value.
You can also do following:
Set ID (e.g. emailSelected) for your toolbar buttons:
jQuery('#list1').jqGrid('navButtonAdd', '#list1_pager', { 'id' : 'emailSelected', 'caption' : 'Email Selected', 'buttonicon' : 'ui-icon-extlink', ....
Connect loadComplete event:
$grid["loadComplete"] = "function(){ gridLoad(); }"; $g->set_options($grid);
On load grid event, traverse all data using JS and if certain data is found in column (e.g. id = 39), hide buttons.
function gridLoad() { var rows = $('#list1').getRowData(); for (var i=0;i<rows.length;i++) { if (rows[i].id == '39') { $("#emailSelected").remove(); } } }