Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@uxf/data-grid

Package Overview
Dependencies
Maintainers
1
Versions
308
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uxf/data-grid

Redux DataGrid

  • 2.0.0-beta.17
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
612
decreased by-9.2%
Maintainers
1
Weekly downloads
 
Created
Source

@uxf/data-grid

Migration from v1 to v2

DataGridConfigurator => removed
LoaderFunction => Loader

-- DataGridProps --
DataGridBo

Example usage

// prepare data
export interface Country {
    code: string;
    name: string;
}

export const countries: Country[] = [
    { code: "AT", name: "Austria" },
    { code: "CZ", name: "Czech Republic" },
    { code: "DE", name: "Germany" },
    { code: "GR", name: "Greece" },
    { code: "HU", name: "Hungary" },
    { code: "IT", name: "Italy" },
    { code: "MT", name: "Malta" },
    { code: "MC", name: "Monaco" },
    { code: "NL", name: "Netherlands" },
    { code: "NO", name: "Norway" },
    { code: "PL", name: "Poland" },
    { code: "PT", name: "Portugal" },
];

export const App: React.FC = () => {
    const [hiddenColumns, setHiddenColumns] = useState<string[]>([]);
    const [selectedRows, setSelectedRows] = useState<Country[]>([]);

    // create config 
    const config = DataGridConfigurator.create()
        .addColumn({ name: "code", label: "Code" })
        .addColumn({ name: "name", label: "Name", sort: true })
        .addFilter({
            name: "code",
            label: "Code",
            type: "select",
            options: countries.map(c => ({ label: c.name, value: c.code })),
        })
        .addFilter({ name: "name", label: "Name", type: "text" })
        .getConfig();
    
    // create loader 
    const loader: Loader = async (_, { dir, page = 1, perPage = 10 }) => {
        const result = countries.sort((a, b) =>
            dir === "asc" ? a.name.localeCompare(b.name) : b.name.localeCompare(a.name),
        );
    
        return {
            count: result.length,
            totalCount: countries.length,
            result: result.slice(page * perPage, page * perPage + perPage),
        };
    };

    return (
        <DataGrid<Country>
            {...config}
            gridName="test"
            title="Test"
            loader={loader}
            onChangeHiddenColumns={setHiddenColumns}
            hiddenColumns={hiddenColumns}
            selectableRows="multiple"
            onChangeSelectedRows={setSelectedRows}
            selectedRows={selectedRows}
        />
    );
};

Keywords

FAQs

Package last updated on 01 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc