1.0.7 • Published 4 years ago

react-yii2-tools v1.0.7

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

Import

    import {Yii2DataProvider} from 'react-yii2-tools'

Example

    import React from "react";


    import {Yii2DataProvider} from 'react-yii2-tools'

    import SearchIcon from '@material-ui/icons/Search';
    import EditIcon from '@material-ui/icons/Edit';

    const createColumnsHeader = (name, label, type, showInTable = true, filter = true, rest) => {
    return {
        name,
        type,
        label,
        filter,
        showInTable,
        ...rest
    }
    }

    const action = (row) => { console.log(row) }

    const columnsHeader = [
    createColumnsHeader('id', 'Id', "primary", false, false),
    createColumnsHeader('username', 'Name', 'text', true),
    ];

    export const Table = () => <Yii2DataProvider
    api={{
        url: 'http://localhost/yii2/basic/web/user',
        headers: {
        //'Authorization': 'Bearer jwtToken'
        }
    }}
    actions={{
        delete: true,
        showWhen: {
        
        },
        buttons: [
        { Icon: <SearchIcon />, onClick: action },
        { Icon: <EditIcon />, onClick: action },
        ]
    }}
    filters
    showPaginationTop
    actionsLabel='Acciones'
    columnsHeader={columnsHeader}
    />;
  

Props

NameTypeDescription
apijsonData for fetch request, url attribute is required
actionsjsonActive actions, showWhen json, buttons array, delete is boolean
filtersboolShow advance filters
showPaginationTopboolput paginations in top of table
paginationjsonlabelRowsPerPage attribute, label rows per page
actionsLabelstringActions Label for column header
searchLabelstringSearch Button Label for filters
advancedFiltersLabelstringAdvanced filters label
columnsHeaderjson{ name, label, number, filter, isPrimary, showInTable, ...rest }
1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.2

4 years ago

1.0.0

4 years ago