Server side using nodejs error on search with client side columns

Server side using nodejs error on search with client side columns

JamesWaldronJamesWaldron Posts: 5Questions: 2Answers: 0

I'm using nodeJS server side processing. My tables has two columns that are both set to 'searchable: false' and 'orderable: false' but when searching or ordering nodeJS errors with the following: 'UnhandledPromiseRegectionWarning: Error: Unknown field: empty (index 0)'

I can see the request being sent has 'columns[0][searchable]: false' and 'columns[0][orderable]: false' in the data so it appears client-side its ok but server side seems to be ignoring that.

Has anyone experienced this with nodejs? and any ideas on a solution?

Answers

  • allanallan Posts: 61,732Questions: 1Answers: 10,110 Site admin

    Have you also changed the default order option, which will default to order on column index 0 (the orderable controls the user's ability to order the column, not the API's).

    Allan

  • JamesWaldronJamesWaldron Posts: 5Questions: 2Answers: 0

    Yes I have this to set the initial order by a date column.

    order: [
    [4, 'desc']
    ],

  • allanallan Posts: 61,732Questions: 1Answers: 10,110 Site admin

    Thanks. Could you either (preferably) give me a link to the page showing the issue, or use the debugger on your page just after the error occurs?

    Allan

  • JamesWaldronJamesWaldron Posts: 5Questions: 2Answers: 0

    Thanks Allan. The page isn't public facing and the data is sensitive. Anyway of getting the debug to you without it being available online?

  • allanallan Posts: 61,732Questions: 1Answers: 10,110 Site admin

    I've been working on a new version of the debugger which secures the data it uploads a bit more - to run this version of the debugger open your browser's console on the page showing the issue and run:

    var n = document.createElement('script');
    n.setAttribute('language', 'JavaScript');
    n.setAttribute('src', 'https://debug.datatables.net/beta/index.js?rand=' + new Date().getTime());
    document.body.appendChild(n);
    

    Then click the "Upload data" option and confirm you want to upload the data. Only myself and Colin will be able to see it (i.e. the two employees of SpryMedia). We'll need the six letter debug code it gives you.

    Thanks,
    Allan

  • JamesWaldronJamesWaldron Posts: 5Questions: 2Answers: 0

    Hi Allan, the code is ajimuz
    Ordering the columns is working. Its just the search that is failing. Below is the nodeJS error:

    UnhandledPromiseRejectionWarning: Error: Unknown field: (index 0)
    at Editor._sspField (C:\Development\nodeJSAPI\node_modules\datatables.net-editor-server\dist\editor.ts:1573:10)
    at Builder.<anonymous> (C:\Development\nodeJSAPI\node_modules\datatables.net-editor-server\dist\editor.ts:1587:24)
    at MSSQL_Formatter.compileCallback (C:\Development\nodeJSAPI\node_modules\knex\lib\formatter.js:161:14)
    at MSSQL_Formatter.rawOrFn (C:\Development\nodeJSAPI\node_modules\knex\lib\formatter.js:104:36)
    at QueryCompiler_MSSQL.whereWrapped (C:\Development\nodeJSAPI\node_modules\knex\lib\query\compiler.js:531:30)
    at QueryCompiler_MSSQL.where (C:\Development\nodeJSAPI\node_modules\knex\lib\query\compiler.js:314:32)
    at C:\Development\nodeJSAPI\node_modules\knex\lib\dialects\mssql\query\compiler.js:49:30
    at Array.map (<anonymous>)
    at QueryCompiler_MSSQL.select (C:\Development\nodeJSAPI\node_modules\knex\lib\dialects\mssql\query\compiler.js:48:33)
    at QueryCompiler_MSSQL.toSQL (C:\Development\nodeJSAPI\node_modules\knex\lib\query\compiler.js:108:27)
    at Builder.toSQL (C:\Development\nodeJSAPI\node_modules\knex\lib\query\builder.js:115:44)
    at C:\Development\nodeJSAPI\node_modules\knex\lib\runner.js:56:32
    From previous event:
    at Runner.run (C:\Development\nodeJSAPI\node_modules\knex\lib\runner.js:51:31)
    at Builder.Target.then (C:\Development\nodeJSAPI\node_modules\knex\lib\interface.js:35:43)
    at process._tickCallback (internal/process/next_tick.js:188:7)
    (node:16524) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
    (node:16524) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This discussion has been closed.