重新将功能应用于表行 [英] Re-apply functions to table rows

查看:71
本文介绍了重新将功能应用于表行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个非常独特的情况(我希望):
我有一个UserControl,可用来创建具有可排序列的表并将上下文菜单添加到每一行.

列排序的工作方式是从tbody中获取每一行,将它们按数组排序,然后删除原始行并追加新排序的行.

上下文菜单在$ {document).ready上起作用,方法是从隐藏行的JSON字符串中读取每一行的JSON项,然后将这些对象的详细信息转换为上下文菜单项(来自www.javascripttoolbox.com [

Hi,

I have a pretty unique (i hope) situation:
I have a UserControl that I can use to create a table with sortable columns and add context menus to each row.

The column sort works by taking each row from the tbody, sorting them in an array, removing the original rows and appending the newly sorted rows.

The context menu works on $(document).ready by reading the items from a JSON string in a hidden column for each row, and translating the details from those objects into context menu items (third party context menu code from www.javascripttoolbox.com[^]).

The problem is that the context menu item functions apply to the rows that are removed when the table is sorted.

So, to the question: How can I either A) better apply the context menu function or B) sort the table tbody section without losing the functions applied.

I don''t have to worry about whether there are other row or cell functions at this stage as I will be the only one using the user control for a while.

many thanks in advance

推荐答案

(document).ready,方法是从隐藏行中的JSON字符串中读取每行的JSON项,并将这些对象的详细信息转换为上下文菜单项(来自 www.javascripttoolbox.com [
(document).ready by reading the items from a JSON string in a hidden column for each row, and translating the details from those objects into context menu items (third party context menu code from www.javascripttoolbox.com[^]).

The problem is that the context menu item functions apply to the rows that are removed when the table is sorted.

So, to the question: How can I either A) better apply the context menu function or B) sort the table tbody section without losing the functions applied.

I don''t have to worry about whether there are other row or cell functions at this stage as I will be the only one using the user control for a while.

many thanks in advance


好吧,我对此问题并没有真正的兴趣,所以我将发布解决方法:


我没有将上下文菜单应用于每行onclick事件,而是应用了一个必须更高效的函数,当您单击该行时会创建上下文菜单:

Ok, I didn''t get any real interest in this issue so I''ll post my work-around:


instead of applying the context menu to each rows onclick event I instead apply a must more efficient function that creates the context menu when you click on the row:

    function ApplyContextMenu() {
        if(jsonCellIndex>=0) {


("
("table[id


这篇关于重新将功能应用于表行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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