0.2.16 • Published 8 years ago

curio-table-ants v0.2.16

Weekly downloads
49
License
-
Repository
-
Last release
8 years ago

table-ants

Installation & Usage

npm install curio-table-ants --save
import TableAnts, {TableAntsProps, TableAntsColumn} from "curio-table-ants"

const props: TableAntsProps = {
    fetchURL: location.origin + "/api/user/all"
}

const columns: TableAntsColumn[] = [
    {
        title: "Email",
        dataIndex: "email",
        key: "email",
        type: "string",
        render(text: any, row: any) {
            return `${text}(${row.name})`
        }
    }
]
render((
    <TableAnts {...props} />
), document.getElementById("#app")

Configuration

TableAntsProps

PropNameTypeDescriptionDefault value
beginnumbera Unix timestampTimestamp of the day 10 days before today
endnumbera Unix timestampTimestamp of now
downloadbooleanDisplay the download button or nottrue
formatstringthe extention of the file to be downloaded".execl"
onTimeChange(ts: number[]) => booleanCall back when timepicker's value is changed
pageSizenumberrow of data in each page20
payloadExtraobjectextra payload required by fetchURL API{}
sheetNamestringthe name of file to be doanloaded"Sheet"
timepickerbooleanDisplay the timepicker or notfalse
pathstringrelative path of data array (in the JSON object returned by fetchURL API)""
baseColorstringa HSL color value, will be used in many components in the tablehsl(132, 40%, 57%)
onDataFetched(data: any) => voidCallback function which is called when data is fetched.
filtersJSX.Element[]A list of cusomized filter component[]
langstringlanguage"en-US"
downloadURLstringthe API that fetch data from fetchURL and return the download linkrequired
fetchURLstringthe API that return actual data (Must be the absolute URL of a HTTP POST APIrequired
totalKeystringrelative path of the total number of data (in the JSON object returned by fetchURL API)required
columnsTableAntsColumn[]Definition of columnsrequired

TableAntsColumn

PropNameTypeDescriptionDefault value
titlestring | JSX.Elementthe column title
dataIndexstringthe key (or path) of data (in a single row).You can imit dataIndex to hide this column in the page
keystringsame as dataIndex.You can omit key to remove this column in the download file
typestringtype in Golang, should be one of int64, string, bool, slice or float64]required if key is present
convstring[]a list of conv functions (conv originial data to readable format in download file)
hideByDefaultbooleanliterally "hide by default"
dlDataIndexstringcolumn will be download only if the column spicified by dlDataIndex is visible in the table
render(text: any, row: any) => string | JSX.Elementrender function
filtersany[]
onFilter(v: string) => void
colSpannumberhow many colspans the column will occupy
widthnumber | string
classNamestring
sorter(a: any, b:any): booleana valid sorter function
0.2.16

8 years ago

0.2.15

8 years ago

0.2.14

8 years ago

0.2.13

8 years ago

0.2.12

8 years ago

0.2.11

8 years ago

0.2.10

8 years ago

0.2.9

8 years ago

0.2.8

8 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago