优化 treeTable 外部方法当 `id` 为匹配到对应实例时的判断

pull/1226/head
贤心 2 years ago
parent 2ca56ae5ee
commit 06982a5051

@ -352,6 +352,7 @@ layui.define(['table'], function (exports) {
treeTable.getNodeDataByIndex = function (id, index) { treeTable.getNodeDataByIndex = function (id, index) {
var that = getThisTable(id); var that = getThisTable(id);
if(!that) return;
return that.getNodeDataByIndex(index, true); return that.getNodeDataByIndex(index, true);
} }
@ -782,6 +783,8 @@ layui.define(['table'], function (exports) {
* */ * */
treeTable.formatNumber = function (id) { treeTable.formatNumber = function (id) {
var that = getThisTable(id); var that = getThisTable(id);
if(!that) return;
var options = that.getOptions(); var options = that.getOptions();
var tableViewElem = options.elem.next(); var tableViewElem = options.elem.next();
@ -875,6 +878,8 @@ layui.define(['table'], function (exports) {
treeTable.sort = function (id) { treeTable.sort = function (id) {
var that = getThisTable(id); var that = getThisTable(id);
if(!that) return;
var options = that.getOptions(); var options = that.getOptions();
var initSort = options.initSort; var initSort = options.initSort;
@ -924,6 +929,8 @@ layui.define(['table'], function (exports) {
// 更新数据 // 更新数据
treeTable.updateNode = function (id, index, newNode) { treeTable.updateNode = function (id, index, newNode) {
var that = getThisTable(id); var that = getThisTable(id);
if(!that) return;
var options = that.getOptions(); var options = that.getOptions();
var treeOptions = options.tree; var treeOptions = options.tree;
var tableView = options.elem.next(); var tableView = options.elem.next();
@ -951,6 +958,8 @@ layui.define(['table'], function (exports) {
// 删除数据 // 删除数据
treeTable.removeNode = function (id, node) { treeTable.removeNode = function (id, node) {
var that = getThisTable(id); var that = getThisTable(id);
if(!that) return;
var options = that.getOptions(); var options = that.getOptions();
var treeOptions = options.tree; var treeOptions = options.tree;
var tableView = options.elem.next(); var tableView = options.elem.next();
@ -1126,8 +1135,10 @@ layui.define(['table'], function (exports) {
return newNodes; return newNodes;
} }
// 获取表格选中状态
treeTable.checkStatus = function (id) { treeTable.checkStatus = function (id) {
var that = getThisTable(id); var that = getThisTable(id);
if(!that) return;
// 需要区分单双选 // 需要区分单双选
var tableData = treeTable.getData(id, true); var tableData = treeTable.getData(id, true);
@ -1418,6 +1429,8 @@ layui.define(['table'], function (exports) {
* */ * */
treeTable.checkNode = function (id, node, checked, callbackFlag) { treeTable.checkNode = function (id, node, checked, callbackFlag) {
var that = getThisTable(id); var that = getThisTable(id);
if(!that) return;
var options = that.getOptions(); var options = that.getOptions();
var tableView = options.elem.next(); var tableView = options.elem.next();
@ -1440,6 +1453,8 @@ layui.define(['table'], function (exports) {
treeTable.checkAllNodes = function (id, checked) { treeTable.checkAllNodes = function (id, checked) {
var that = getThisTable(id); var that = getThisTable(id);
if(!that) return;
var options = that.getOptions(); var options = that.getOptions();
var tableView = options.elem.next(); var tableView = options.elem.next();

Loading…
Cancel
Save