Php 如何在jqgrid中仅为用户/管理员隐藏/显示编辑按钮?
我有一个具有编辑/删除/添加功能的jqgrid。我只想显示那些操作项,如果用户有管理员权限。对于除管理员权限以外的所有人,不应在jqgrid导航栏中看到编辑/删除或添加按钮。 我正在使用PHP对用户进行身份验证。现在,登录到该网站的用户可以执行添加、编辑和删除操作 以下是我的jqgrid代码:Php 如何在jqgrid中仅为用户/管理员隐藏/显示编辑按钮?,php,jquery,jqgrid,Php,Jquery,Jqgrid,我有一个具有编辑/删除/添加功能的jqgrid。我只想显示那些操作项,如果用户有管理员权限。对于除管理员权限以外的所有人,不应在jqgrid导航栏中看到编辑/删除或添加按钮。 我正在使用PHP对用户进行身份验证。现在,登录到该网站的用户可以执行添加、编辑和删除操作 以下是我的jqgrid代码: function doOneGrid() { var data={}; data.PRODUCT = prod; data.RELEASE=rel; prod = $("#productCombo")
function doOneGrid()
{
var data={};
data.PRODUCT = prod;
data.RELEASE=rel;
prod = $("#productCombo").val();
rel = $("#releaseCombo").val();
jQuery("#list").jqGrid({
url:"/ProductionScheduler/controller/productcontroller.php?q=2&prod="+prod+"&rel="+rel,
datatype: "json",
type:"POST",
height: 450,
colNames:['Product','Version','ProductionVersion','Status','ProductionStatus','Production','PackagingStatus','PackagingDate','SanityStatus','To_Sanity', 'STStatus','To_ST','eeQSStatus','To_eeQS','GAStatus','To_GA','Notes','Milestones'
],
colModel:[
{name:'Product',index:'Product', width:150,align:"center",sorttype:"string",editable:true,edittype:"select",editoptions:{value:"Default:;OSV:OSV;OSB:OSB;SBC:SBC;LogManager:LogManager;Fusion for Outlook:Fusion for Outlook;Fusion for Lync/MOC:Fusion for Lync/MOC"},formoptions:{rowpos:1},editrules:{required:true}},
{name:'Version',index:'Version', width:150,align:"center",sorttype:"string",hidden:true,editable:true,hidedlg: true,editrules: { edithidden: true },edittype:"select",editoptions:{value:"V8:V8;V7R1:V7R1;V7:V7;V6:V6"}},
{name:'ProductionVersion',index:'ProductionVersion',title:"false",editable:true, width:250,align:"center",sorttype:"string",cellattr: function () { return 'style="white-space: normal;"'}},
{name:'Status',index:'Status', width:100,align:"center",sorttype:"string",editable:true,edittype:"select",editoptions:{value:"Planned:Planned;Produced:Produced;In Sanity:In Sanity; In System Test:In System Test; In Field Trial:In Field Trial; In GA:In GA;TBD:TBD;N/A:N/A;Removed:Removed;Canceled:Canceled"}},
{name:'ProductionStatus',index:'ProductionStatus', width:100,align:"center",hidden:true,editable:true,hidedlg: true, editrules: { edithidden: true },edittype:"select",editoptions:{value:"Default:;Actual:Actual;Plan:Planned"}},
{name:'Production',index:'ProductionDate', width:100,align:"center",editable:true,sorttype:"date"},
{name:'PackagingStatus',index:'PackagingStatus', width:100,align:"center",hidden:true,editable:true,hidedlg: true, editrules: { edithidden: true },edittype:"select",editoptions:{value:"Default:;Actual:Actual;Plan:Planned"}},
{name:'Packaging',index:'PackagingDate', width:100,align:"center",sorttype:"date",hidden:true,editable:true,hidedlg: true, editrules: { edithidden: true }},
{name:'SanityStatus',index:'SanityStatus', width:100,align:"center",hidden:true,editable:true,hidedlg: true, editrules: { edithidden: true },edittype:"select",editoptions:{value:"Default:;Actual:Actual;Plan:Planned"}},
{name:'To_Sanity',index:'Sanity_Regression_Date', width:100, align:"center",sorttype:"date",editable:true},//jsonmap:"cell.1.value"
{name:'STStatus',index:'STStatus', width:100,align:"center",hidden:true,editable:true,hidedlg: true, editrules: { edithidden: true },edittype:"select",editoptions:{value:"Default:;Actual:Actual;Plan:Planned"}},
{name:'To_ST',index:'ST_Date', width:100, align:"center",sorttype:"date",editable:true},//formatter:myFormatter},
{name:'eeQSStatus',index:'eeQSStatus', width:100,align:"center",hidden:true,editable:true,hidedlg: true, editrules: { edithidden: true },edittype:"select",editoptions:{value:"Default:;Actual:Actual;Plan:Planned"}},
{name:'To_eeQS',index:'eeQS_Date', width:100, align:"center",sorttype:"date",editable:true},//formatter:myFormatter},
{name:'GAStatus',index:'GAStatus', width:100,align:"center",hidden:true,editable:true,hidedlg: true, editrules: { edithidden: true },edittype:"select",editoptions:{value:"Default:;Actual:Actual;Plan:Planned"}},
{name:'To_GA',index:'GA_Date', width:100, align:"center",sorttype:"date",editable:true},//,formatter:myFormatter},
{name:'Notes',index:'Notes', width:200, align:"center",sorttype:"string",editable:true,cellattr: function () { return 'style="white-space: normal;"'}},//cellattr: function () { return 'style=\"background:orange\"'}},
{name:'Milestones',index:'Milestones', width:100, align:"center",sorttype:"string",editable:true,cellattr: function () { return 'style="white-space: normal;"'}},
],
rowNum:25,
rowList:[50,100,300],
pager: '#pager',
sortname: 'ProductionVersion',
sortorder: "desc",
editurl:"/ProductionScheduler/controller/action.php",
viewrecords: true,
autowidth: true,
caption: "Schedule",
onCellSelect:function(rowid,icol, cellcontent,e){
var dataFromTheRow=jQuery('#list').jqGrid ('getRowData', rowid);
},
subGrid : true,
subGridUrl: "/ProductionScheduler/controller/subgrid.php?q=1",
subGridModel: [
{ name : ['Product','Release','Field_Updated','Old_Value', 'New_Value','Update_Type','Name_Updated','Date_Created','Notes'],
width : [80,80,80,80,80,80,80,80],
params:['Product','ProductionVersion'],
sortname:['DateCreated'],
sortorder: "asc"
} ]
});
jQuery("#list").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true,defaultSearch:"cn"});
jQuery("#list").jqGrid('navGrid','#pager',{del:true,add:true,edit:true,search:true,cloneToTop:true},{},{},{},{multipleSearch:true});
}
有两种方法可以做到这一点:
var permission=$('#hidden').val();
$('#list').jqGrid({
...
loadComplete:function(){
if(权限===xxx){
$(“#编辑”).hide();
}
})
.navButtonAd(“#列表”{id:“编辑”,…}
}