简体   繁体   中英

JqGrid Checkbox enable/disable via function

I wanna be able to disable/enable a jqGrid checkbox based on a bool value passed back from a function. How would I do this?

snippet of code below

 colModel: [
    { name: 'IsSystemAdmin', index: 'IsSystemAdmin', width: 50, align: "center", 
    formatter: "checkbox", 
    formatoptions: { disabled: isSystemAdmin}, editable: true }
],

* Please note where I call the function: formatoptions: { disabled: isSystemAdmin}, editable: true } *


var isSystemAdmin = new function(){
   //do something and return a bool value
}

or

function isSystemAdmin(){
  //do something and return a bool value
}

Resolved apparently the code I have above does in fact work. Only Change :

formatoptions: { disabled: isSystemAdmin()}

instead of

formatoptions: { disabled: isSystemAdmin}

Use the .jqGrid('setSelection' method

function isSystemAdmin() { 
  jQuery("#list13").jqGrid('setSelection',"13"); 
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM