在行上单击根据该行中单元格的内容禁用/启用按钮

发布于 2024-09-29 04:42:44 字数 409 浏览 0 评论 0原文

我目前正在使用 flexigrid.js 插件,并且有一个按钮,我希望根据当前所选行中的某个单元格是否等于某个值来启用/禁用该按钮。

这是我目前所在的位置: 我想将以下内容添加到回调函数列表中,但我不知道在 if 语句中放入什么(如果这甚至是有效的检查)。

'onRowClick': function(row,grid){
                        var content = $(row).attr('content');
                        if ($content == 'target'){

                        }

虽然此回调函数未注册,但 'onDblClick':function... 确实有效。

I'm currently using the flexigrid.js plugin and there is a button that I wish to enable/disable depending on whether a certain cell in the currently selected row is equal to a certain value.

Here is where I am currently at:
I thought to add the following to the list of callback functions but am stuck as to what to put in the if statement if that is even a valid check.

'onRowClick': function(row,grid){
                        var content = $(row).attr('content');
                        if ($content == 'target'){

                        }

This callback function does not register though, the 'onDblClick':function... does work however.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鲜血染红嫁衣 2024-10-06 04:42:44

我收到了来自 Flexigrid for jQuery google 小组将其复制到此处以供参考

在colModel参数中
flexigrid,您可以传递回调
具有名称进程的函数。在那
你可以挂接到一个函数上的函数
单击一行时调用该函数。
我知道这听起来很困难。一个例子
会更清楚。这是:

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 将被调用,如果您单击
在一行中,会显示一条警报。希望
这有帮助。
此致,马克

I received an answer from Marc Borgers from the Flexigrid for jQuery google group copied it here for reference

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文