1

I would like to know if it's possible to hide the little trash can button if the user logged in has a certain category.

The condition should be something like this,

<?PHP IF(($_SESSION['usuarioSCB'] -> categoria) != 'Administrativo de gestión interna'): ?>

but I don't know where or how to put it in my grid code.

Right now I have a standard navGrid also.

jQuery("#tab_contactos").jqGrid('navGrid','#list_contactos',{
     edit:true, 
     add:true, 
     del:true, 
     pdf:true, 
     refresh:false
   } 
});

Thanks.

Vinoth Krishnan
  • 2,925
  • 6
  • 29
  • 34
Molina
  • 13
  • 3

1 Answers1

0

I used local data to load the grid here,

var mydata = [
  {"UserName":"8125579231","RoleId":1,"Name":"Sreekanth","RoleName":"Administrator"},
  {"UserName":"9676078986","RoleId":1,"Name":"Karteek","RoleName":"Administrator"} ];
    var myGrid = $("#list2"),
    myGridId = $.jgrid.jqID(myGrid[0].id);
    myGrid.jqGrid({
        caption: "Employee Details",
        data: mydata,
        datatype: "local",
        colNames: ["UserName", "RoleId", "Name", "RoleName"],
        colModel: [
              { name: "UserName", index: 'UserName', width: 150 },
              { name: 'RoleId', index: "RoleId", width: 150 },
              { name: "Name", index: "Name", width: 150 },
              { name: "RoleName", index: "RoleName", width: 150 }
        ],
        rowNum: 10,
        pager: '#jQGridDemoPager',
        sortname: "UserName",
        viewrecords: true,
        sortorder: "desc"
}).jqGrid('navGrid', '#jQGridDemoPager');

// This line will disable the delete button
$("#del_" + myGridId).addClass('ui-state-disabled');

My reference is Oleg's answer.

You have to add your condition to this line,

<?PHP IF(($_SESSION['usuarioSCB'] -> categoria) != 'Administrativo de gestión interna'){ ?>
    $("#del_" + myGridId).addClass('ui-state-disabled');
<?PHP 
  } 
?>

Disabled delete button

See the Demo for disabled delete button.

Community
  • 1
  • 1
Vinoth Krishnan
  • 2,925
  • 6
  • 29
  • 34