Search only finds strings that start with the search value

Search only finds strings that start with the search value

philostowphilostow Posts: 4Questions: 2Answers: 0

I'm using datatables.net in my Django application. I have overarching enabled. The search works but it only finds the string if the string appears at the beginning of the column. In other words, searching for, "Mr. Blue", will find rows where there is a column containing, "Mr. Blue", but it won't find rows that have a column containing, "Good morning Mr. Blue". How do I fix this? Here's my JS:

    $(document).ready(function() {
        var dt_table = $('#radiological').DataTable({
            select: true,
            language: dt_language,
            order: [[ 0, "asc" ]], 
            lengthMenu: [[10, 25, 50, 75, 100], [10, 25, 50, 75, 100]],
            columnDefs: [
                {orderable: true,
                 searchable: true,
                 className: "center",
                 visible: true,
                 targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
                },
                {orderable: true,
                 searchable: false,
                 className: "never",
                 visible: false,
                 targets: [11, 12, 13, 14, 15, 16, 17]
                },
                {
                    data: 'id',
                    targets: [0]
                },
                {
                    data: 'subject_id',
                    targets: [1]
                },
                {
                    data: 'admission_id',
                    targets: [2]
                },
                {
                    data: 'ds_row_id',
                    targets: [3]
                },
                {
                    data: 'ds_category',
                    targets: [4]
                },
                {
                    data: 'ds_description',
                    targets: [5]
                },
                {
                    data: 'rr_row_id',
                    targets: [6]
                },
                {
                    data: 'rr_category',
                    targets: [7]
                },
                {
                    data: 'rr_description',
                    targets: [8]
                },
                {
                    data: 'td',
                    targets: [9]
                },
                {
                    data: 'is_annotated',
                    targets: [10]
                },
                {
                    data: 'is_concordant',
                    targets: [11]
                },
                {
                    data: 'is_related',
                    targets: [12]
                },
                {
                    data: 'has_relevant_findings',
                    targets: [13]
                },
                {
                    data: 'notes',
                    targets: [14]
                },
                {
                    data: 'user_id',
                    targets: [15]
                },
                {
                    data: 'create_date',
                    targets: [16]
                },
                {
                    data: 'last_modified',
                    targets: [17]
                }
            ],
            searching: true,
            processing: true,
            serverSide: true,
            ajax: RADIOLOGY_LIST_JSON_URL
        });
    });

Answers

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    Since you have serverSide: true, the searching, sorting and paging functions are the responsibility of the server script. The server side processing protocol is discussed [here]. You will need to change the queries performed by your Django scripts to provide the expected results.

    Maybe you don't need server side processing enabled. Start with this faq. The search() API docs provide details of searching when using client side processing.

    Kevin

  • philostowphilostow Posts: 4Questions: 2Answers: 0

    Ah, thanks.

This discussion has been closed.