Hide/Disable custom buttons on load in the grid header?

QuestionsHide/Disable custom buttons on load in the grid header?
Tim Moore asked 3 years ago

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?

View post on imgur.com

//////////////////////////
// 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

 

 

 

3 Answers
Abu Ghufran Staff answered 3 years ago

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.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Abu Ghufran Staff answered 3 years ago

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();
		}
	}
}	
_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Tim Moore answered 3 years ago

Abu,

This was what I was looking for. I need to buy a book on jquery.

Again, you support is always above and beyond.

Thanks,

Tim

Your Answer

1 + 9 =

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?