Search Builder Not Recognizing Date Column

Search Builder Not Recognizing Date Column

NaveenVarmaNaveenVarma Posts: 4Questions: 2Answers: 0

I am using Datatable for displaying table data. Data have few date columns. While sorting Datatable recognize date column and sorts as per date format. But while filtering data using search builder, instead of date filter options it displays String related filter options. Please help me out. As can be seen from the attachments. curr_gr_wef is date field and can be sorted as date format. But search builder is giving string filter options.

Answers

  • khanzainkhanzain Posts: 1Questions: 0Answers: 0

    The issue you're facing occurs because DataTables SearchBuilder doesn't automatically detect date columns for filtering. To fix this, you need to define the column's type as "date" in the DataTable initialization. You can use columns.type or create a custom filter for dates in SearchBuilder. Here's an example:

    $('#example').DataTable({
        columns: [
            { data: 'curr_gr_wef', type: 'date' },
            // other columns
        ],
        searchBuilder: {
            columns: [0], // adjust the column index as needed
        }
    });
    

    Ensure the date format is consistent across your data to enable proper filtering.

    Still have doubts here are some excellent programm learning platforms that can guide you through your learning journey:-
    1. W3school 2. Iqra Technology 3. Javatpoint

  • NaveenVarmaNaveenVarma Posts: 4Questions: 2Answers: 0

    Thank you very much for response. But the problem is we don't know what data will come in which column. We are using single jsp page for all reports. Is there any way to determine date format in this case. I am using datatime and moment plug-in. Please guide me.

  • NaveenVarmaNaveenVarma Posts: 4Questions: 2Answers: 0

    Also I want to add In my pc environment , search builder displays date related filter options. The issue is when in production environment only.

Sign In or Register to comment.