antd/lib/table/interface#RowSelectionType TypeScript Examples

The following examples show how to use antd/lib/table/interface#RowSelectionType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.tsx    From next-basics with GNU General Public License v3.0 6 votes vote down vote up
/**
   * @kind RowSelectionType
   * @required false
   * @default -
   * @description 选框类型(单选/多选),影响优先级低于configProps.rowSelection.type
   */
  @property({
    attribute: false,
  })
  type: RowSelectionType;
Example #2
Source File: StoryPageAddModal.tsx    From datart with Apache License 2.0 5 votes vote down vote up
StoryPageAddModal: React.FC<IProps> = props => {
  const {
    visible,
    onSelectedPages,
    onCancel,
    pageContents: dataCharts,
  } = props;
  const [selectedDataChartIds, setSelectedDataChartIds] = useState<string[]>(
    [],
  );
  const onOk = () => {
    onSelectedPages(selectedDataChartIds);
  };
  useEffect(() => {
    if (!visible) {
      setSelectedDataChartIds([]);
    }
  }, [visible]);

  const columns = [
    {
      title: '名称',
      dataIndex: 'name',
      render: (text: string) => text,
    },
    {
      title: '描述',
      dataIndex: 'description',
      render: (text: string) => text,
    },
  ];
  const rowSelection = {
    type: 'checkbox' as RowSelectionType,
    selectedRowKeys: selectedDataChartIds,
    onChange: (keys: React.Key[]) => {
      setSelectedDataChartIds(keys as string[]);
    },
  };

  return (
    <Modal
      title="add StoryPage"
      visible={visible}
      onOk={onOk}
      centered
      onCancel={onCancel}
      okButtonProps={{ disabled: !selectedDataChartIds.length }}
      cancelButtonProps={{ disabled: false }}
    >
      <Table
        rowKey={record => record.relId}
        rowSelection={rowSelection}
        columns={columns}
        pagination={{ pageSize: 6 }}
        dataSource={dataCharts}
      />
    </Modal>
  );
}