Table的placeholder支持下tpl,以及修复了远程拉取数据后,不触发校验的问题

This commit is contained in:
rickcole 2019-05-30 15:10:42 +08:00
parent 144f4165cd
commit 923b06cb9d
2 changed files with 17 additions and 3 deletions

View File

@ -929,6 +929,8 @@ export default class Table extends React.Component<TableProps, object> {
classnames: cx, classnames: cx,
classPrefix: ns, classPrefix: ns,
checkOnItemClick, checkOnItemClick,
render,
data
} = this.props; } = this.props;
return ( return (
@ -980,7 +982,12 @@ export default class Table extends React.Component<TableProps, object> {
}) })
) : ( ) : (
<tr className={cx('Table-placeholder')}> <tr className={cx('Table-placeholder')}>
<td colSpan={columns.length}>{placeholder}</td> <td colSpan={columns.length}>
{render('placeholder', {
type: 'tpl',
tpl: placeholder
}, {data})}
</td>
</tr> </tr>
)} )}
</tbody> </tbody>
@ -1317,7 +1324,7 @@ export default class Table extends React.Component<TableProps, object> {
} }
render() { render() {
const {className, store, placeholder, classnames: cx} = this.props; const {className, store, placeholder, classnames: cx, data, render} = this.props;
this.renderedToolbars = []; // 用来记录哪些 toolbar 已经渲染了,已经渲染了就不重复渲染了。 this.renderedToolbars = []; // 用来记录哪些 toolbar 已经渲染了,已经渲染了就不重复渲染了。
const heading = this.renderHeading(); const heading = this.renderHeading();
@ -1377,7 +1384,12 @@ export default class Table extends React.Component<TableProps, object> {
this.renderRows(store.rows) this.renderRows(store.rows)
) : ( ) : (
<tr className={cx('Table-placeholder')}> <tr className={cx('Table-placeholder')}>
<td colSpan={store.filteredColumns.length}>{placeholder}</td> <td colSpan={store.filteredColumns.length}>
{render('placeholder', {
type: 'tpl',
tpl: placeholder
}, {data})}
</td>
</tr> </tr>
)} )}
</tbody> </tbody>

View File

@ -352,6 +352,8 @@ export const FormItemStore = types
(getRoot(self) as IRendererStore).notify('error', self.errors.join('')); (getRoot(self) as IRendererStore).notify('error', self.errors.join(''));
} else { } else {
clearError(); clearError();
self.validated = false; // 拉完数据应该需要再校验一下
let options:Array<IOption> = json.data.options || json.data.items || json.data.rows || json.data || []; let options:Array<IOption> = json.data.options || json.data.items || json.data.rows || json.data || [];
options = normalizeOptions(options as any); options = normalizeOptions(options as any);
setOptions(options); setOptions(options);