Server Side & search builder. Two calls to the server

Server Side & search builder. Two calls to the server

uk101manuk101man Posts: 1Questions: 1Answers: 0
edited May 18 in Free community support

Hi,

I have the below configured:

var posTable = new DataTable('#posTable', {
    processing: true,
    serverSide: true,
    filter: false,
    orderMulti: false,
    pageLength: 15,
    responsive: true,
    dom: 'QBfrtip',
    lengthChange: false,
    buttons: ['searchBuilder', 'colvis', 'pageLength'],
    rowId: 'id',
    ajax: {
        url: '/posTableAjax',
        type: 'POST',
        datatype: 'json',
        data: function (d) {
            d.startdate = sday;
            d.enddate = eday;
        }       
    },
    searchBuilder: {
        liveSearch: false,
        conditions: {
            date: {
                '!null': null,
                '!=': null,
                'not': null,
                '>=': null,
                '>': null,
                '<=': null,
                '<': null,
                'null': null,
                '!between': null
            },
            string: {
                'ends': null,
                '!ends': null,
                '!contains': null,
                '!starts': null,
                'null': null,
                '!null': null,
                '!=': null,
            },
            html: {
                'ends': null,
                '!ends': null,
                '!contains': null,
                '!starts': null,
                'null': null,
                '!null': null,
                '!=': null,
            },
            num: {
                '<': null,
                '<=': null,
                '>': null,
                '>=': null,
                'between': null,
                '!between': null,
                'null': null,
                '!null': null,

            },
        },
        preDefined: {

            criteria: [{
                condition: 'between',
                "data": 'Created Date',
                "value": [moment().subtract(3, 'days').format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')]
            }, {
                condition: '=',
                "data": 'Document Type',
                "value": ['Invoice']
            }
            ],
            logic: 'AND'
        }
    },
    columns: [
        {
            targets: 0,
            className: 'details-control',
            orderable: false,
            data: null,
            defaultContent: ''
        },
        { data: 'id', name: 'id', autoWidth: true },
        { data: 'masterPO', name: 'masterPO', autoWidth: true },
        { data: 'otherRef', name: 'otherRef', autoWidth: true },
        { data: 'flag', name: 'flag', autoWidth: true },
        {
            data: 'createdDate', name: 'createdDate', autoWidth: true, type: 'date', render: function (data) {
                return moment(data, 'YYYY/MM/DD h:m:s').format('DD/MM/YYYY');
            }
        },
        {
            data: 'deliveryDate', name: 'deliveryDate', autoWidth: true, type: 'date', render: function (data) {
                return moment(data, 'YYYY/MM/DD h:m:s').format('DD/MM/YYYY');
            }
        },
        {
            data: 'completedDate', name: 'completedDate', autoWidth: true, type: 'date', render: function (data) {
                return moment(data, 'YYYY/MM/DD h:m:s').format('DD/MM/YYYY');
            }
        },
        { data: 'staffFullName', name: 'staffFullName', autoWidth: true },
        { data: 'sapSupplierID', name: 'sapSupplierID', autoWidth: true },
        { data: 'supplierName', name: 'supplierName', autoWidth: true },     
        { data: 'totalPriceExVat', name: 'totalPriceExVat', autoWidth: true },
    ]
});

When the page is loaded, I see a server call, with no search builder and then a second one with the search build data.

Is this to be expected?

Sign In or Register to comment.