Okay
  Public Ticket #1860460
Filter with MSSQL datasource
Closed

Comments

  •  2
    jko5er started the conversation

    Hi, can anyone verify if they can use filters with a MSSQL datasource? I've tried putting my query in a SQL view, turned on/off server-side processing, and I still cannot get filters to work. Please advise.

    Thanks!

  •  2
    jko5er replied

    Now that I look at it, I am unable to turn off Server-side Processing. Every time I disable it and apply, the page refreshed and it loads as enabled. Is there something with MSSQL that is forcing Server side to be enabled?

  •  2,572
    Aleksandar replied

    Hello jko5er.

    Sorry for late response. 

    Our company is located in Serbia and our working time is from 10:00 to 17:00 CET. business days.

    The MySQL table type can be used to any limit, but the server-side processing feature is mandatory for data sets exceeding 3000-4000 rows. Having that in mind, if You have a lot of rows, the plugin will automatically turn on server side processing and that's the default behavior of wpDataTables.

    If your MySQL-query based wpDataTable doesn’t work correctly with server-side processing, probably this is happening because wpDataTables server has problems with parsing of the query and building new queries dynamically (rarely happens, but does sometimes). To avoid this please prepare a MySQL view (a stored query), which will return the data that you need, call it e.g. “view1” and then build a wpDataTabled based on a simple query like “SELECT * FROM view1″.

    Please note some this when working with the server-side processing feature:

    • Please do not use “LIMIT” in the SELECT statement. wpDataTables adds it automatically and it will be overridden.
    • Please do not use “ORDER BY” in the SELECT statement. wpDataTables has its own sorting engine so it makes no sense to use MySQL’s sorting, since it will be overridden. Also, server-side processing feature adds this part of statement automatically when users trigger the sorting on the front-end, and having it in initial statement may cause the table to crash.

    Please let me know if creating a view resolves the issue.

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  2
    jko5er replied

    Hi Aleksandar, I did create a view and can filter string fields, but am still unable to filter date range. This is MSSQL, not MySQL. I had created a MSSQL view as you instructed, but it did not make a difference for dates.

    My date field is stored in MSSQL in datetime2. I am converting it in the view to yyyy-mm-dd.

    Are the date range filters expecting a different format for the date, even if I choose yyyy-mm-dd in the WPDatatables settings?

  •  2,572
    Aleksandar replied

    Hello again jko5er.

    It doesn't really matter if you're using MSSQL or MySQL, the logic and concept is the same.

    Can you check PHPMyAdmin format for the date column? It has to be the same as in wpDataTables settings, so instead of changing it in the view, can you check in the database and change if possible?

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  2
    jko5er replied

    I cannot use phpmyadmin since this is for Microsoft SQL Server. When checking in Management Studio, it shows my column is datetime2, then in my SQL view, I am converting it to date.

    Do the filters work with data that is converted in SQL? Or am I better off leaving the original datetime2 format?

    I am unable to change the source column format as it is part of an application. It doesn't make sense why WPDatatables would see the data any differently in the filter if my view presents it in a different format

  •  2,572
    Aleksandar replied

    Hello again jko5er.

    Understood. datetime2's default string literal format is:

    YYYY-MM-DD hh:mm:ss[.fractional seconds]
    

    So if you set the column's in wpDataTables to be Datetime with the same format, it should work. Creating a view resolves the issue with searching and filtering of the table.

    You can also provide me a temporary WP-admin login for your site where this happens, so we could log in and take a look ‘from the inside’ as that’s the most efficient way to see and resolve the issue. We do not interfere with any data or anything else except for the plugin (in case that’s a production version of the site), and of course we do not provide login data to third party. You can write credentials here just check Private Reply so nobody can see them except us.

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables