Skip to main content

This package provides easy integration between Django REST framework and DevExtreme Data Grid. It handles grouping, paging, filtering, aggregating and ordering on serverside.

Project description

htec-drf-dx-datagrid

Overview

This package provides easy integration between Django REST framework and DevExtreme Data Grid. It handles grouping, paging, filtering, aggregating and ordering on serverside.

In which case should you use htec-drf-dx-datagrid?

You have DevExtreme in the frontend and Django REST framework as the backend. And your data is too large to load at once, but you want use grouping and filtering.

How it works?

Htec-drf-dx-datagrid supports devextreme load options in HTTP-request and returns data in format fully compatible with Data Grid. All you need is to replace classname "ModelViewSet" with "DxModelViewSet" in your django project

Installation

pip install htec-drf-dx-datagrid

Configuration

Define your ModelViewSet class inherits from DxModelViewSet:

from htec_drf_dx_datagrid import DxModelViewSet


class MyModelViewSet(DxModelViewSet):
    serializer_class = MyModelSerializer
    queryset = MyModel.objects.all()

Also you can define ReadOnlyModelViewSet inherits from DxReadOnlyModelViewSet

from htec_drf_dx_datagrid import DxModelViewSet


class MyReadOnlyModelViewSet(DxReadOnlyModelViewSet):
    serializer_class = MyModelSerializer
    queryset = MyModel.objects.all()

Example for React.js:

const load = (loadOptions) => {
    return axios(`${my_url}`, {
            params: loadOptions
        }
    ).then((response) => response.data
    )
}

export default class Example extends PureComponent {
   state={
       store: new CustomStore({ load: load})
   }

    render() {
        return (<DataGrid
                    dataSource={this.state.store}
                    height={"100vh"}
                >
                    <RemoteOperations groupPaging={true}/>
                    <Scrolling mode={'virtual'}/>
                    <HeaderFilter visible={true} allowSearch={true}/>
                    <Paging defaultPageSize={40}/>
                    <Sorting mode={"multiple"}/>
                    <FilterRow visible={true}/>
                    <GroupPanel visible={true}/>
                    <Grouping autoExpandAll={false}/>
                    <Summary>
                        <TotalItem column={"id"} summaryType={"count"}/>
                        <GroupItem column={"name"} summaryType={"max"}/>
                    </Summary>
                </DataGrid>
        );
    }
}

Example for jQuery.js:

        const load = (loadOptions) => {
            return axios(`${my_url}`, {
                    params: loadOptions
                }
            ).then((response) => response.data
            )
        }

        const store = new DevExpress.data.CustomStore({load: load});
        $("#gridContainer").dxDataGrid({
            dataSource: store,
            height: "100vh",
            remoteOperations: {
                groupPaging: true
            },
            scrolling: {mode: 'virtual'},
            headerFilter: {visible: true, allowSearch: true},
            paging: {defaultPageSize: 40},
            sorting: {mode: "multiple"},
            filterRow: {visible: true},
            groupPanel: {visible: true},
            grouping: {autoExpandAll: false},
            summary: {
                totalItems: [{
                    column: "id",
                    summaryType: "count"
                }],
                groupItems: [{
                    column: "id",
                    summaryType: "min"
                }]
            }
        });

By default, filtering is case-sensitive.If you want case-insensitive behavior, you must set FILTER_CASE_SENSITIVE parameter to false in django settings:

REST_FRAMEWORK = {
    'DRF_DX_DATAGRID': {
        'FILTER_CASE_SENSITIVE': False}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

htec_drf_dx_datagrid-0.5.7.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

htec_drf_dx_datagrid-0.5.7-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file htec_drf_dx_datagrid-0.5.7.tar.gz.

File metadata

  • Download URL: htec_drf_dx_datagrid-0.5.7.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.8

File hashes

Hashes for htec_drf_dx_datagrid-0.5.7.tar.gz
Algorithm Hash digest
SHA256 bbfd6ba6487e15e7a138e306a64cae9069eb8df0fc56ce6b69d48061512a1d82
MD5 b9a5b544d404eb23c2c329775665d1ac
BLAKE2b-256 b6ba03a7a5f4dc9d735b9e50281c7732f2140d60fcfe79b84f0466739e30122f

See more details on using hashes here.

File details

Details for the file htec_drf_dx_datagrid-0.5.7-py3-none-any.whl.

File metadata

File hashes

Hashes for htec_drf_dx_datagrid-0.5.7-py3-none-any.whl
Algorithm Hash digest
SHA256 585f057104ff6ae4e6a21b83e1d338b0b7eb0828f9761368bdb191e0673e6bf5
MD5 5939446ffaf3efd5058461acfb8ff5bf
BLAKE2b-256 dda4c2a9c2d7ab0b299e83bd139169deda14dd5addb6664da96346fd3d5d9d52

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page