javascript - How to disable tabs in JqGrid at runtime? -


two default grids defenition:

initialise(){ $("#expensetable").jqgrid({     datatype : "local",     mtype : 'get',     colmodel : [ {name:'expnsid',label:'id', width:150 },                   {name:'username',label:'name', width:150 },                  {name:'catname',label:'category', width:150 },                  {name:'date',label:'date', width:150 },                  {name:'amount',label:'amount', width:150 },                  {name:'status',label:'status', width:150 }],     pager : '#exppager',     rownum : 10,     rowlist : [ 10, 20, 30 ],     sortname : 'invid',     sortorder : 'desc',     viewrecords : true,     autowidth : false,     caption : 'expenses details',     onselectrow : function(expnsid) { dispexpensdata(expnsid); }     });  $("#tabs").tabs(); gettokens();//gets tokens logged in user. refreshexpensegrid();//populates data grid displeavegrid();// ll call next default grid  }  }  $("#leavetable").jqgrid({     datatype : "local",     mtype : 'get',     colmodel : [ {name:'leaveid',label:'id', width:150 },                   {name:'username',label:'name', width:150 },                  {name:'fdate',label:'date', width:150 },                          {name:'tdate',label:'date', width:150 }                  {name:'status',label:'status', width:150 }],     pager : '#exppager',     rownum : 10,     rowlist : [ 10, 20, 30 ],     sortname : 'invid',     sortorder : 'desc',     viewrecords : true,     autowidth : false,     caption : 'leave applications',     onselectrow : function(leaveid) { displeavedata(leaveid); }     });  refreshleavegrid();//populates data grid securedui();//this ll call below function, check whether remaining tabs can visible or not 

secured ui function:

function securedui(){   var sectoken = "deleteuser"; if(!checkroletoken(sectoken)){//if users dont have token delete user, buttons ll disabled     $('#expdelete').attr('disabled', 'disabled');     $('#lvedelete').attr('disabled', 'disabled');     $('#deluser').attr('disabled', 'disabled');     $('#roledel').attr('disabled', 'disabled');     $('#tokendel').attr('disabled', 'disabled'); }   var sectoken= "viewuser"; if(checkroletoken(sectoken)){     showuserdetails();//3rd grid defn:contains table definition user grid.     initialiserole();//4th grid defn: role grid     showtokens();//5th grid defn: token grid } 

check token:

function checkroletoken(newtoken){ for( var = 0; i<tokens.length; i++ ){     var token = tokens[i];//tokens cache, contains tokens assigned current user.     if(newtoken == token.tokenname){         return true;     } } return false;  } 

the html page:

<script type="text/javascript"> $(document).ready(function() {     initialise(); }); </script> 

the leavetable 2nd grid , have 3 more grids. dont want show them of users, instead admin users should able see them. tokens key find user have right operation in application. tokens, assigned user loaded client-side cache array tokens.

every function add, delete, update & view have tokens @ start of function stored in variable. token variable sent checktoken() argument. there check token against token cache. ll return true or false. operation cancelled or continued according result.

in above code, @ end of leavetable grid defenition, can see function call securedui();. inside function doing 2 things. 1.disabling delete buttons, 2.disabling 3rd, 4th & 5th grids, dont have tokens deleteuser & viewuser.

actually getting is, 3rd, 4th & 5th grids not getting displayed have token viewuser. @ functions securedui() & checktoken(), should do!!! securedui() have viewuser token , current user also, checktoken() should return true, should if block , execute functions calls inside if block. not doing it. cant able clue going wrong.

so, turned on firebug , checked step step. magically, going if block , shows grid admin users. felt worked turned turned off firebug , reloaded page again. ooops, again 3 remaining grids not displaying. can able idea problem!!!

any suggestions!!!

it seems me should place javascript code inside of jquery(document).ready handle: jquery(document).ready(function() {/* place code here */});

if use handle, please post more full code of example inclusive full html code. can reduce code example have example more compact. important problem stay in code , can reproduce problem.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -