我如何知道 jQuery dataTable 的哪一行被单击了?
我想使用 jQuery dataTables 插件在表列中包含删除链接。我确信这很容易。我添加列没有问题,并且我知道实际删除表的语法,我只是不知道单击的行。
这些行是通过 UI 动态添加的,因此除了开头的标题之外,我不会渲染任何行。
I want to include a delete link in a table column, using the jQuery dataTables plugin. I am certain this is easy. I have no problem adding columns, and I know the syntax for actually removing the table, I just don't know the row that is clicked on.
The rows are added dynamically through the UI, so I'm not rendering any rows other than the header in the beginning.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
另一个例子...
});
another example...
});
我最近这样做是为了隐藏/显示每行的额外信息。这是我的代码片段:
我必须在 else 中添加对 null 的检查,因为如果单击附加信息,它会向展开行中的每个项目添加一个简短的空扩展名。
稍后将处理程序添加到表中:
I did this recently to hide/show extra info for each row. Here's a snippet of my code:
I had to add that check against null in the else because it would add a short empty extension to each item in the expanded row if the additional info was clicked.
Later add the handler to the table:
在创建时动态为每行分配一个唯一的 id,并使每行的单击事件删除具有该 id 的元素
Dynamically assign each row a unique id on creation and make the click event for each row remove the element with that id