使用下拉菜单和复选框构建JQGrid [英] Building JQGrid with Dropdowns and checkboxes

查看:110
本文介绍了使用下拉菜单和复选框构建JQGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用jqgrids显示静态值.但是我有一种情况,我需要在JQGrid列中显示复选框和下拉值.取决于我是选中还是取消选中该复选框.关于如何使用下拉菜单和复选框构建jqgrids的任何想法或意见?

I have used jqgrids to display static values. But I have a scenario where I need to have checkboxes and dropdown values to be displayed in JQGrid columns. Depending upon whether I check or uncheck the checkbox. Any thoughts or comments on how to build jqgrids with Dropdowns and Checkboxes?

推荐答案

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

You can use the checkbox formatter to display a cell as a checkbox. As part of the 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函数:

As for the dropdown, you can pass a custom format function to the editrow function:

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

然后,在此函数内,您想创建一个SELECT(或所需的任何下拉列表):

Then, inside this function you would want to create a SELECT (or whatever dropdown you need):

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

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

So when you edit the row the data will be displayed in a dropdown.

这篇关于使用下拉菜单和复选框构建JQGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆