bootstrap-table - 在 getAllSelections 中,我可以只获取某些列吗?

问题描述 投票:0回答:1

我正在使用 bootstrap-table (https://bootstrap-table.com/)。我通过 ajax 从 Active Directory 加载用户列表,在数据加载后,我想从显示的行中获取两列数据 (cn,dn)。其中一些行已被选择。用户选择或取消选择某些行后,我将获取这些新的/更改的数据并将其与加载的原始数据进行比较。

我目前正在使用

加载“原始”数据
JSON.stringify($table.bootstrapTable('getAllSelections') method  

但我有无关的数据,我只想要 2 列(cn 和 dn)。有没有办法过滤“getAllSelections”方法?

php ajax bootstrap-table
1个回答
0
投票

如果您只需要每个数组对象中的两个字段并假设您需要 DistinguishedName 和 cn:

https://examples.bootstrap-table.com/index.html#methods/get-selections.html#view-source

我已经在我的系统上对此进行了测试,它返回了我期望的结果。

var results = $table.bootstrapTable('getSelections').map(function(elem, index) {
   return {
      cn: elem.cn,
      distinguishedName: elem.distinguishedName
   };
});
console.dir (results) 
var JSON = JSON.stringify(results)
console.dir (JSON)
© www.soinside.com 2019 - 2024. All rights reserved.