mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:58:05 +08:00
fix:自定义列显示问题修复
This commit is contained in:
parent
566294c421
commit
158b6957b7
@ -450,14 +450,15 @@ order: 67
|
||||
"expandableOn": "this.record.id === 1 || this.record.id === 3",
|
||||
"keyField": "id",
|
||||
"expandedRowClassNameExpr": "<%= data.rowIndex % 2 ? 'bg-success' : '' %>",
|
||||
"expandedRowKeys": ["3"]
|
||||
},
|
||||
"expandableBody": [
|
||||
{
|
||||
"type": "tpl",
|
||||
"html": "<div class=\"test\">测试测试</div>"
|
||||
}
|
||||
]
|
||||
"expandedRowKeys": ["3"],
|
||||
"type": "container",
|
||||
"body": [
|
||||
{
|
||||
"type": "tpl",
|
||||
"html": "<div class=\"test\">测试测试</div>"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -498,14 +499,15 @@ order: 67
|
||||
"expandableOn": "this.record.id === 1 || this.record.id === 3",
|
||||
"keyField": "id",
|
||||
"expandedRowClassNameExpr": "<%= data.rowIndex % 2 ? 'bg-success' : '' %>",
|
||||
"expandedRowKeysExpr": "data.record.id == '3'"
|
||||
},
|
||||
"expandableBody": [
|
||||
{
|
||||
"type": "tpl",
|
||||
"html": "<div class=\"test\">测试测试</div>"
|
||||
}
|
||||
]
|
||||
"expandedRowKeysExpr": "data.record.id == '3'",
|
||||
"type": "container",
|
||||
"body": [
|
||||
{
|
||||
"type": "tpl",
|
||||
"html": "<div class=\"test\">测试测试</div>"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -164,13 +164,15 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
||||
if (Array.isArray(options.columns)) {
|
||||
options.columns.forEach((column: any) => {
|
||||
let value: any;
|
||||
// 兼容新老版本的name和key
|
||||
const key = column.name || column.key;
|
||||
if (
|
||||
column.searchable &&
|
||||
column.name &&
|
||||
(value = getVariable(self.query, column.name))
|
||||
key &&
|
||||
(value = getVariable(self.query, key))
|
||||
) {
|
||||
items = matchSorter(items, value, {
|
||||
keys: [column.name]
|
||||
keys: [key]
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -249,7 +251,6 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
||||
hasNext,
|
||||
items: oItems,
|
||||
rows: oRows,
|
||||
columns,
|
||||
...rest
|
||||
} = result;
|
||||
|
||||
@ -308,13 +309,14 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
||||
if (Array.isArray(options.columns)) {
|
||||
options.columns.forEach((column: any) => {
|
||||
let value: any;
|
||||
const key = column.name || column.key;
|
||||
if (
|
||||
column.searchable &&
|
||||
column.name &&
|
||||
(value = getVariable(self.query, column.name))
|
||||
key &&
|
||||
(value = getVariable(self.query, key))
|
||||
) {
|
||||
filteredItems = matchSorter(filteredItems, value, {
|
||||
keys: [column.name]
|
||||
keys: [key]
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -331,8 +333,8 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
||||
data.count = data.total = filteredItems.length;
|
||||
}
|
||||
|
||||
if (Array.isArray(columns)) {
|
||||
self.columns = columns.concat();
|
||||
if (Array.isArray(options.columns)) {
|
||||
self.columns = options.columns.concat();
|
||||
} else {
|
||||
self.columns = undefined;
|
||||
}
|
||||
|
@ -962,7 +962,7 @@ export default class CRUD2 extends React.Component<CRUD2Props, any> {
|
||||
const {store} = this.props;
|
||||
|
||||
store.updateColumns(store.columns.map((c: any, i: number) => ({
|
||||
...c, toggled: (index === i ? toggled : c.toggled)
|
||||
...c, toggled: (index === i ? toggled : (c.toggled !== false))
|
||||
})));
|
||||
}
|
||||
|
||||
|
@ -123,10 +123,10 @@ export class ColumnTogglerRenderer extends React.Component<ColumnTogglerRenderer
|
||||
onClick={async () => {
|
||||
const {data, dispatchEvent} = this.props;
|
||||
let columns = activeToggaleColumns.map((item: any) => item);
|
||||
if (!column.toggled) {
|
||||
if (column.toggled !== false) {
|
||||
columns.push(column);
|
||||
} else {
|
||||
columns = columns.filter((c: any) => c.name !== column.name);
|
||||
columns = columns.filter((c: any) => c.key !== column.key);
|
||||
}
|
||||
const rendererEvent = await dispatchEvent(
|
||||
'columnToggled',
|
||||
@ -139,7 +139,7 @@ export class ColumnTogglerRenderer extends React.Component<ColumnTogglerRenderer
|
||||
return;
|
||||
}
|
||||
|
||||
toggleToggle && toggleToggle(!column.toggled, index);
|
||||
toggleToggle && toggleToggle(!(column.toggled !== false), index);
|
||||
}}
|
||||
>
|
||||
<Checkbox size="sm" classPrefix={ns} checked={column.toggled !== false}>
|
||||
|
Loading…
Reference in New Issue
Block a user