从localStorage的数据表中删除行订货后 [英] Delete row from localStorage in Datatables after ordering

查看:169
本文介绍了从localStorage的数据表中删除行订货后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我测试数据表插件,需要一些建议。我的问题是,我无法订货后删除我的表中的特定行。对于删除行我使用的.index()方法。这里是我的小提琴

I'm testing Datatables plugin and need some advice. My problem is that I can't delete a specific row in my table after ordering. For removing rows I use .index() method. Here is my fiddle

起初我找到最接近行:

var row = $(this).closest('tr');

然后用这个code设置索引编号:

then using this code to set index number:

var index = $("#example tbody").children().index(row);

当然,订购此索引号更改后。
您能否提供一些更有效?

And of course after ordering this index number changes. Can you suggest something more efficient?

推荐答案

考虑名称作为唯一的入口:

Considering name as unique entry:

var name = $(row).find('td:first').text();
for (var i = 0; i < dataSort.length; i++) {
  if (dataSort[i][0] == name) {
    break;
  }
}
dataSort.splice(i, 1);

小提琴这里

这篇关于从localStorage的数据表中删除行订货后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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