带有可编辑复选框列的jqGrid [英] jqGrid with an editable checkbox column
问题描述
当使用jqGrid时,如何强制单元格在页面加载时以及单击时加载其可编辑视图?
When using jqGrid how do you force a cell to load in its editable view on page load as well as when it is clicked?
如果设置'单元格编辑'如下所示,只有单击单元格时才会出现复选框。
If you set up 'cell editing' like below, the check box only appears when you click on the cell.
{ name: 'MyCol', index: 'MyCol', editable:true, edittype:'checkbox', editoptions: { value:"True:False" },
cellEdit:true,
另外点击复选框,有没有办法立即向服务器发送AJAX帖子而不必依赖用户按Enter键?
Also on clicking checkbox, is there a way of sending a AJAX post to server instantly rather than having to rely on the user pressing enter?
推荐答案
要允许复选框始终可点击,请使用复选框格式化程序的已禁用
属性:
To allow the checkboxes to always be click-able, use the checkbox formatter's disabled
property:
{ name: 'MyCol', index: 'MyCol',
editable:true, edittype:'checkbox', editoptions: { value:"True:False"},
formatter: "checkbox", formatoptions: {disabled : false} , ...
回答你的问题第二个问题,你必须为复选框设置一个事件处理程序,这样当单击一个函数时,会调用一个函数,例如,向服务器发送一个AJAX POST。这里有一些示例代码可以帮助您入门。您可以将此添加到 loadComplete
事件:
To answer your second question, you will have to setup an event handler for the checkboxes, such that when one is clicked a function is called to, for example, send an AJAX POST to the server. Here is some example code to get you started. You can add this to the loadComplete
event:
// Assuming check box is your only input field:
jQuery(".jqgrow td input").each(function(){
jQuery(this).click(function(){
// POST your data here...
});
});
这篇关于带有可编辑复选框列的jqGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!