我目前正在使用 flexigrid.js 插件,我希望根据当前所选行中的某个单元格是否等于某个值来启用/禁用一个按钮。
这是我目前所在的位置: 我想将以下内容添加到回调函数列表中,但对于在 if 语句中放入什么甚至是有效检查仍然很困惑。
'onRowClick': function(row,grid){
var content = $(row).attr('content');
if ($content == 'target'){
}
虽然这个回调函数没有注册,但是 'onDblClick':function...
确实有效。
最佳答案
我收到了来自 Marc Borgers 的回复来自 Flexigrid for jQuery谷歌组复制到这里以供引用
In the colModel parameter of flexigrid, you can pass a callback function with name process. In that function you can hook on a function that is called when a row is clicked. I know it sounds difficult. An example will make more clear. Here it is:
function procMe(celDiv,id) {
$(celDiv).click(
function () {alert(this.innerHTML + " " + id); }
);
};
function postFlexigrid()
{
$("#flex1").flexigrid
(
{
url: 'yourURL',
dataType: 'json',
colModel : [
{display: 'Name', name : 'xxx', width : 200, sortable : false,
align: 'left', process: procMe}
],
usepager: false,
singleSelect: true,
title: 'x',
useRp: false,
showTableToggleBtn: true,
height: 150
}
);
}
$(document).ready(function() {
postFlexigrid();
});
procMe
will be called and if you click on a row, an alert is shown. Hope this helps.
Regards, Marc
关于javascript - 在行上单击根据该行中单元格的内容禁用/启用按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4001597/