使用下拉列表和复选框构建JQGrid

时间:2010-02-16 19:13:13

标签: javascript jquery jqgrid

我使用jqgrids来显示静态值。但我有一个场景,我需要在JQGrid列中显示复选框和下拉值。取决于我是选中还是取消选中复选框。关于如何使用Dropdown和Checkboxs构建jqgrids的任何想法或意见?

1 个答案:

答案 0 :(得分:28)

您可以使用checkbox格式化程序将单元格显示为复选框。作为colmodel的一部分:

// A checkbox that is read-only until the user edits the row
{name:'my_checkbox',index:'my_checkbox', editable:true, 
 edittype:"checkbox", formatter:'checkbox' }

// A checkbox that may be edited at any time
{name:'my_clickable_checkbox',index:'my_clickable_checkbox', sortable:true, 
 formatter: "checkbox", formatoptions: {disabled : false}, editable: true,
 edittype:"checkbox"}

对于下拉列表,您可以将自定义格式函数传递给editrow函数:

jQuery('#mygrid').editRow(id, true, formatEditors);

然后,在这个函数中你需要创建一个SELECT(或你需要的任何下拉列表):

function formatEditors(id) {
    // Your drop down code here...
    // EG: jQuery("#"+id+"_myDropDownRow","#mygrid").
}

因此,当您编辑行时,数据将显示在下拉列表中。

相关问题