4
我是新的發展反應我有一個項目,我必須在我的桌子上添加過濾器和排序功能,我真的不知道從哪裏開始。以下模板: 如何繼續? 過濾和排序反應
import * as React from 'react';
import { SPComponentLoader } from '@microsoft/sp-loader';
import styles from '../components/SearchSpfx.module.scss';
import { ISearchSpfxWebPartProps } from '../ISearchSpfxWebPartProps';
import * as moment from 'moment';
export interface ITableTemplate extends ISearchSpfxWebPartProps {
\t results: any[];
}
export default class TableTemplate extends React.Component<ITableTemplate, {}> {
\t private iconUrl: string = "https://spoprod-a.akamaihd.net/files/odsp-next-prod_ship-2016-08-15_20160815.002/odsp-media/images/filetypes/16/";
\t private unknown: string[] = ['aspx', 'null'];
\t private getAuthorDisplayName(author: string): string {
\t \t if (author !== null) {
\t \t \t const splits: string[] = author.split('|');
\t \t \t return splits[1].trim();
\t \t } else {
\t \t \t return "";
\t \t }
\t }
\t private getDateFromString(retrievedDate: string): string {
\t \t if (retrievedDate !== null) {
\t \t \t return moment(retrievedDate).format('DD/MM/YYYY');
\t \t } else {
\t \t \t return "";
\t \t }
\t }
\t public render(): JSX.Element {
\t \t // Load the Office UI Fabrics components css file via the module loader
\t SPComponentLoader.loadCss('https://appsforoffice.microsoft.com/fabric/2.6.1/fabric.components.min.css');
\t \t return (
\t \t \t <div className={styles.searchSpfx}>
\t \t \t \t {
\t \t \t \t \t (() => {
\t \t \t \t \t \t // Check if you need to show a title
\t \t \t \t \t \t if (this.props.title !== "") {
\t \t \t \t \t \t \t return <h1 className='ms-font-xxl'>{this.props.title}</h1>;
\t \t \t \t \t \t }
\t \t \t \t \t })()
\t \t \t \t }
\t \t \t \t <table className={`ms-Table ${styles.templateTable}`}>
\t \t \t \t \t <thead>
\t \t \t \t \t \t <tr>
\t \t \t \t \t \t \t <th>Type</th>
\t \t \t \t \t \t \t <th>Name</th>
\t \t \t \t \t \t \t <th>Modified</th>
\t \t \t \t \t \t \t <th>Modified by</th>
\t \t \t \t \t \t </tr>
\t \t \t \t \t </thead>
\t \t \t \t \t <tbody>
\t \t \t \t \t \t {
\t \t \t \t \t \t \t this.props.results.map((result, index) => {
\t \t \t \t \t \t \t \t return (<tr key={index}>
\t \t \t \t \t \t \t \t \t \t \t <td>
\t \t \t \t \t \t \t \t \t \t \t \t <a href={result.Path}><img src={`${this.iconUrl}${result.Fileextension !== null && this.unknown.indexOf(result.Fileextension) === -1 ? result.Fileextension : 'code'}.png`} alt="File extension"/></a>
\t \t \t \t \t \t \t \t \t \t \t </td>
\t \t \t \t \t \t \t \t \t \t \t <td>
\t \t \t \t \t \t \t \t \t \t \t \t <a href={result.Path}>{result.Filename !== null ? result.Filename.substring(0, result.Filename.lastIndexOf('.')) : ""}</a>
\t \t \t \t \t \t \t \t \t \t \t </td>
\t \t \t \t \t \t \t \t \t \t \t <td>{this.getDateFromString(result.ModifiedOWSDATE)}</td>
\t \t \t \t \t \t \t \t \t \t \t <td>{this.getAuthorDisplayName(result.EditorOWSUSER)}</td>
\t \t \t \t \t \t \t \t \t \t </tr>);
\t \t \t \t \t \t \t })
\t \t \t \t \t \t }
\t \t \t \t \t </tbody>
\t \t \t \t </table>
\t \t \t </div>
\t \t);
\t }
}
謝謝你們