How to use the tubular-common.GridRequest function in tubular-common

To help you get started, we’ve selected a few tubular-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github unosquare / tubular-nodejs / src / connectors / jsondata.spec.js View on Github external
it(" combines search and filter", done => {
            const take = 10,
                filteredCount = 1;

            let request = new GridRequest(
                [
                    {
                        name: 'first_name', label: 'First Name', sortable: true, searchable: true, filter: {
                            name: '',
                            text: 'Merrick',
                            argument: [],
                            operator: CompareOperators.Equals,
                            hasFilter: false
                        }
                    },
                    {
                        name: 'last_name', label: 'Last Name', sortable: true, searchable: true, filter: {
                            name: '',
                            text: 'Probart',
                            argument: [],
                            operator: CompareOperators.Equals,
github unosquare / tubular-nodejs / src / connectors / jsondata.spec.js View on Github external
it(" use free text search", done => {
            const take = 10,
                filteredCount = 2;

            let request = new GridRequest(
                [
                    { name: 'first_name', label: 'First Name', sortable: true, searchable: true },
                    { name: 'last_name', label: 'Last Name', sortable: true, searchable: true },
                    { name: 'address_id', label: 'Address Id', sortable: true, searchable: false }
                ],
                take,
                0,
                'And'
            );

            tubular.createGridResponse(request, data)
                .then(response => {
                    expect(response.counter).toBeDefined();
                    expect(response.totalRecordCount).toBe(totalRecordCount);
                    expect(response.filteredRecordCount).toBe(filteredCount);
                    expect(response.totalPages).toBe(Math.ceil(filteredCount / take));
github unosquare / tubular-nodejs / src / connectors / jsondata.spec.js View on Github external
it("skipping first 10 and taking 20", done => {
            const take = 20,
                filteredCount = 49;

            let request = new GridRequest([
                {
                    name: 'first_name', label: 'First Name', sortable: true, searchable: true, filter: {
                        name: '',
                        text: 'Ignacius',
                        argument: [],
                        operator: CompareOperators.NotEquals,
                        hasFilter: false
                    }
                },
                { name: 'last_name', label: 'Last Name', sortable: true, searchable: true },
                { name: 'address_id', label: 'Address Id', sortable: true, searchable: false }
            ],
                take,
                0);

            tubular.createGridResponse(request, data)
github unosquare / tubular-nodejs / src / connectors / knex.spec.js View on Github external
it(" use free text search", done => {
            const take = 10,
                filteredCount = 31;

            let queryBuilder = knex.select('first_name', 'last_name', 'address_id').from('customer');

            let request = new GridRequest(
                [
                    { name: 'first_name', label: 'First Name', sortable: true, searchable: true },
                    { name: 'last_name', label: 'Last Name', sortable: true, searchable: true },
                    { name: 'address_id', label: 'Address Id', sortable: true, searchable: false }
                ],
                take,
                0,
                'And',
            );

            tubular.createGridResponse(request, queryBuilder)
                .then(response => {
                    expect(response.counter).toBeDefined();
                    expect(response.totalRecordCount).toBe(totalRecordCount);
                    expect(response.filteredRecordCount).toBe(filteredCount);
                    expect(response.totalPages).toBe(Math.ceil(filteredCount / take));
github unosquare / tubular-nodejs / src / connectors / knex.spec.js View on Github external
it(" filters by one column", done => {
            const take = 10,
                filteredCount = 1;

            let queryBuilder = knex.select('first_name', 'last_name', 'address_id').from('customer');


            let request = new GridRequest(
                [
                    {
                        name: 'first_name', label: 'First Name', sortable: true, searchable: true, filter: {
                            name: '',
                            text: 'JOY',
                            argument: [],
                            operator: CompareOperators.Contains,
                            hasFilter: false
                        }
                    },
                    { name: 'last_name', label: 'Last Name', sortable: true, searchable: true },
                    { name: 'address_id', label: 'Address Id', sortable: true, searchable: false }
                ],
                take,
                0,
                'GEO'
github unosquare / tubular-nodejs / src / connectors / jsondata.spec.js View on Github external
it("filters using Gt", done => {
            const take = 10,
                filteredCount = 1;

            let request = new GridRequest(
                [
                    { name: 'first_name', label: 'First Name', sortable: true, searchable: true },
                    { name: 'last_name', label: 'Last Name', sortable: true, searchable: true },
                    {
                        name: 'address_id', label: 'Address Id', sortable: true, searchable: false, filter: {
                            name: '',
                            text: 49,
                            argument: [],
                            operator: CompareOperators.Gt,
                            hasFilter: false
                        }
                    }
                ],
                take,
                0,
            );
github unosquare / tubular-nodejs / src / connectors / knex.spec.js View on Github external
it("skipping first 10 and taking 20", done => {
            const take = 20,
                filteredCount = 598;

            let queryBuilder = knex.select('first_name', 'last_name', 'address_id').from('customer');

            let request = new GridRequest(
                [
                    {
                        name: 'first_name', label: 'First Name', sortable: true, searchable: true, filter: {
                            name: '',
                            text: 'Patricia',
                            argument: [],
                            operator: CompareOperators.NotEquals,
                            hasFilter: false
                        }
                    },
                    { name: 'last_name', label: 'Last Name', sortable: true, searchable: true },
                    { name: 'address_id', label: 'Address Id', sortable: true, searchable: false }
                ],
                take,
                0,
            );
github unosquare / tubular-nodejs / src / connectors / jsondata.spec.js View on Github external
it(" filters by one column", done => {
            const take = 10,
                filteredCount = 1;

            let request = new GridRequest(
                [
                    {
                        name: 'first_name', label: 'First Name', sortable: true, searchable: true, filter: {
                            name: '',
                            text: 'ucy',
                            argument: [],
                            operator: CompareOperators.Contains,
                            hasFilter: false
                        }
                    },
                    { name: 'last_name', label: 'Last Name', sortable: true, searchable: true },
                    { name: 'address_id', label: 'Address Id', sortable: true, searchable: false }
                ],
                take,
                0,
                'GEO'
github unosquare / tubular-nodejs / src / connectors / knex.spec.js View on Github external
it(" combines search and filter", done => {
            const take = 10,
                filteredCount = 1;

            let queryBuilder = knex.select('first_name', 'last_name', 'address_id').from('customer');


            let request = new GridRequest(
                [
                    {
                        name: 'first_name', label: 'First Name', sortable: true, searchable: true, filter: {
                            name: '',
                            text: 'ANDREW',
                            argument: [],
                            operator: CompareOperators.Equals,
                            hasFilter: false
                        }
                    },
                    {
                        name: 'last_name', label: 'Last Name', sortable: true, searchable: true, filter: {
                            name: '',
                            text: 'PURDY',
                            argument: [],
                            operator: CompareOperators.Equals,
github unosquare / tubular-react / src / Hooks / useTubular.ts View on Github external
exportTo: async (allRows: boolean, exportFunc: (payload: any[], columns: ColumnModel[]) => void) => {
            if (getState.filteredRecordCount === 0) {
                return;
            }

            let payload: any[] = getState.data;
            if (allRows) {
                const { Payload } =
                    await getAllRecords(new GridRequest(getColumns, -1, 0, getSearchText));
                payload = Payload;
            }

            exportFunc(payload, getColumns);
        },
        goToPage: (page: number) => {