0

I'm using Yajra DataTables in Laravel and experiencing issues with the search functionality for the modefied column (HAWB). I've modified the HAWB column definition to display a clickable link, but searching on the actual HAWB value isn't working.

return DataTables::of($data)
    ->addIndexColumn()
    ->addColumn('HAWB', function ($row) {
        $url = route('shipment_tracking') . "?trknbr=" . $row->HAWB;
        return "<a href='$url' target='_blank'>$row->HAWB</a>";
    })
    ->rawColumns(['HAWB'])
    ->make(true);

` $('#airwaybill-tracking').DataTable({ pageLength: 10, processing: true, serverSide: true,

    ajax: route.admin_dashboard,
    columns: [,
        {
            data: 'HAWB',
            name: 'HAWB',
            className: 'text-sm',
        },
     ]`
});

I'm using Laravel with Yajra DataTables package I'm using server-side processing

What I've Tried:

I've verified the route configuration for route('shipment_tracking'). I've used console logs to check the search term and generated URL. I've tried temporarily disabling other column definitions to isolate conflicts.

Expected Behavior: Users should be able to search for HAWB numbers, even though the column displays a link.

Actual Behavior: Searching doesn't seem to work correctly for the HAWB column.

1 Answer 1

0

Replace your Controller Code:

return DataTables::of($data)
    ->addIndexColumn()
    ->editColumn('HAWB', function ($row) {
        $url = route('shipment_tracking') . "?trknbr=" . $row->HAWB;
        return "<a href='$url' target='_blank'>$row->HAWB</a>";
    })
    ->rawColumns(['HAWB'])
    ->make(true);

In then inspite of addColumn use editColumn then you will also be able to search that field

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.