在 YUI 数据表中最后单击的行上调用单击事件

发布于 2024-09-04 20:54:00 字数 485 浏览 3 评论 0原文

我有一个 YUI 数据表,并且有一个在单击一行时调用的函数:

...
YAHOO.keycoes.myDatatable = myDatatable;
...
myDatatable.subscribe("rowClickEvent", oneventclickrow);
var oneventclickrow = function( args ) {
    ...
}

我想在数据表中当前突出显示的行上调用订阅 rowClickEvent 的函数(最后一次单击的行)。

我尝试做这样的事情:

YAHOO.keycoes.myDatatable.getSelectedRows()[0].rowClickEvent()

但是 getSelectedRows() 不返回任何行。如何获取数据表中突出显示的行,然后调用与 rowClickEvent 关联的函数?

I have a YUI datatable and I have a function which is invoked when I click on a row:

...
YAHOO.keycoes.myDatatable = myDatatable;
...
myDatatable.subscribe("rowClickEvent", oneventclickrow);
var oneventclickrow = function( args ) {
    ...
}

I'd like to invoke the function subscribed to rowClickEvent on the row which is currently highlighted in the datatable (the row which was clicked for the last time).

I've tried to do something like this:

YAHOO.keycoes.myDatatable.getSelectedRows()[0].rowClickEvent()

but getSelectedRows() doesn't return any row. How can I get the highlighted row in the datatable and then call the function associated with rowClickEvent?

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

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

发布评论

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

评论(1

别理我 2024-09-11 20:54:00

当我展示 YUI 数据表功能时,这里是一个强大的应用程序。查看其源代码以深入了解我如何使用 YUI 数据表。

我使用像这样的助手

var datatableUtils = {
    getSelected:function(datatable) {
        var records = datatable.getRecordSet().getRecords();

        for(var i = 0; i < records.length; i++) {
            if(datatable.isSelected(records[i])) {
                return records[i];
            }
        }

        return null;
    },
    removeAll:function(datatable) {
        var records = datatable.getRecordSet().getRecords();

        for(var i = (records.length - 1); i >= 0; i--) {
            datatable.deleteRow(records[i]);
        }
    },
    removeSelected:function(datatable) {
        datatable.deleteRow(datatableUtils.getSelected(datatable));
    },
    selectAll:function(datatable) {
        var records = datatable.getRecordSet().getRecords();

        for(var i = 0; i < records.length; i++) {
            datatable.selectRow(records[i]);
        }
    }
};

,当我想订阅某些事件时,我会执行以下操作

datatable.user.subscribe("rowClickEvent", function(args) {
  /**
    * Keep in mind this keyword refers To YUI datatable instance 
    *
    * args.target allows yui get row clicked
    */

     if(this.isSelected(args.target)) {
         alert("row selected");
     }
}

我希望它有用

Here goes a powerful application when i show YUI datatable funcionality. See its source code To get a good insight how i use YUI datatable.

I use a helper like

var datatableUtils = {
    getSelected:function(datatable) {
        var records = datatable.getRecordSet().getRecords();

        for(var i = 0; i < records.length; i++) {
            if(datatable.isSelected(records[i])) {
                return records[i];
            }
        }

        return null;
    },
    removeAll:function(datatable) {
        var records = datatable.getRecordSet().getRecords();

        for(var i = (records.length - 1); i >= 0; i--) {
            datatable.deleteRow(records[i]);
        }
    },
    removeSelected:function(datatable) {
        datatable.deleteRow(datatableUtils.getSelected(datatable));
    },
    selectAll:function(datatable) {
        var records = datatable.getRecordSet().getRecords();

        for(var i = 0; i < records.length; i++) {
            datatable.selectRow(records[i]);
        }
    }
};

And when i want to subscribe some event, i do as follows

datatable.user.subscribe("rowClickEvent", function(args) {
  /**
    * Keep in mind this keyword refers To YUI datatable instance 
    *
    * args.target allows yui get row clicked
    */

     if(this.isSelected(args.target)) {
         alert("row selected");
     }
}

I hope It can be useful

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