我正在使用 bootstrap-table (https://bootstrap-table.com/)。我通过 ajax 从 Active Directory 加载用户列表,在数据加载后,我想从显示的行中获取两列数据 (cn,dn)。其中一些行已被选择。用户选择或取消选择某些行后,我将获取这些新的/更改的数据并将其与加载的原始数据进行比较。
我目前正在使用
加载“原始”数据JSON.stringify($table.bootstrapTable('getAllSelections') method
但我有无关的数据,我只想要 2 列(cn 和 dn)。有没有办法过滤“getAllSelections”方法?
如果您只需要每个数组对象中的两个字段并假设您需要 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)