hermawanramadhan / CodeIgniter4-DataTables

MIT License
92 stars 38 forks source link

Unable to Search Column with Conditional Logic in Hermawan DataTables #49

Open nurissetiabudi opened 1 month ago

nurissetiabudi commented 1 month ago

Description: I encountered an issue where I cannot search a column that uses conditional logic (if) in Hermawan DataTables. Specifically, when defining a custom column using add(), if the logic involves an if statement, the column becomes unsearchable in the DataTables interface.

Steps to Reproduce:

Define a DataTable using Hermawan DataTables. Use the add() method to define a custom column with conditional logic (if statement). Attempt to search within this custom column in the DataTables interface. Expected Behavior: The column defined with conditional logic (if statement) should be searchable in the DataTables interface. Users should be able to filter and search based on the values derived from the conditional logic.

Actual Behavior: The column is not searchable. Attempts to search within the column in the DataTables interface yield no results or do not function as expected.

Code Example:

->add('status_dihubungi', function($row){ if ($row->periksa_status_dihubungi == 1) { return "Sudah Dihubungi"; } else { return "Belum Dihubungi"; } })

Additional Information: This issue seems to be related to how Hermawan DataTables handles columns defined with conditional logic during server-side processing. It affects the usability of DataTables in scenarios where dynamic content based on conditional statements needs to be searchable.