浏览代码

Impriving the removeByUniqueId

Dennis Hernández 10 年之前
父节点
当前提交
1afc80c4b7
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      src/bootstrap-table.js

+ 11 - 0
src/bootstrap-table.js

@@ -1846,6 +1846,17 @@
             if (!row.hasOwnProperty(uniqueId)) {
             if (!row.hasOwnProperty(uniqueId)) {
                 continue;
                 continue;
             }
             }
+
+            if (typeof row[uniqueId] === 'string') {
+                id = id.toString();
+            } else if (typeof row[uniqueId] === 'number') {
+                if ((Number(row[uniqueId]) === row[uniqueId]) && (row[uniqueId] % 1 === 0)) {
+                    id = parseInt(id);
+                } else if ((row[uniqueId] === Number(row[uniqueId])) && (row[uniqueId] !== 0)) {
+                    id = parseFloat(id);
+                }
+            }
+
             if (row[uniqueId] === id) {
             if (row[uniqueId] === id) {
                 this.options.data.splice(i, 1);
                 this.options.data.splice(i, 1);
             }
             }