Best way to implement full boolean data type support (SearchBuilder, server-side processing)

Best way to implement full boolean data type support (SearchBuilder, server-side processing)

supermindsupermind Posts: 27Questions: 5Answers: 0

DataTables and Editor supports date, string and num data types natively (+ formatted/html). We have lot of boolean fields in our application and few of them are nullable. I did not find any helpful discussion about implementing full boolean data type support including SearchBuilder and server side processing.

We format all true values as 'Yes' and false values as 'No', which works great. Editing values inline just by typing in 1, True, 0 or False goes smoothly and even null handling in saving works quite well when saving empty value.

However, using SearchBuilder to show only null values, 0 AND nulls or 1 AND nulls does not work at all. What we need is basicly three choises in selections: 'Yes', 'No' and 'Empty'. Is there somebody who have implemented something like that?

Answers

  • necrotosnecrotos Posts: 12Questions: 3Answers: 0

    You have to define your own SearchBuilder plugin, Please read this following link:
    https://datatables.net/extensions/searchbuilder/plugins

  • necrotosnecrotos Posts: 12Questions: 3Answers: 0
    edited August 2023

    This is maybe weird solution but its working if you use server side processing:

    $('#table').on('xhr.dt', function (e, settings, json, xhr) { json.searchBuilder = { options: { boolColumnName: [{ value: "true", label: "True" }, { value: "false", label: "False" }] } }; }) .DataTable({})

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    When you say it doesn't work at all, what doesn't work? Are you seeing errors? It would be worth knocking out a simple SearchBuilder example that demonstrates the issue, so we can understand the issue the better.

    This example here may be useful. It's using a columns.render for the selected checkbox, that's then also being used by SearchBuilder too.

    Colin

Sign In or Register to comment.