Checkbox\Boolean search returns all data if search is blank

Checkbox\Boolean search returns all data if search is blank

cj1005cj1005 Posts: 142Questions: 45Answers: 1

Hi,

I have 2 boolean columns called 'Active' and 'OnHold', and each has a related preset filter button that sets these filters, also these buttons show the count within each filter (i.e. button 1 caption is 'Active (22)' and button 2 caption is 'OnHold (7)'.

This works great, except if there are no records on hold, when this is the case it sets the filter to show everything rather than nothing, and also the button caption shows the total count rather than 0.

This only affects boolean fields, it works as expected for string fields.

This might be by design? If so, is there a way to detect if the searchBuilder detects no data for the filter, so I can at least disable the 'OnHold' button and set the caption to 'OnHold(0)'?

Thanks, Chris

Answers

  • cj1005cj1005 Posts: 142Questions: 45Answers: 1

    I've been messing around with this & I believe the issue is because seachBuilder auto-detects the available values for the specified column when you select the 'equals' condition, so when the value '1' is not an existing option (as no records exist yet with a value of '1') it is unable to do the filter and just returns all rows.

    For boolean field types, it would be good to preset the selectable values as 1 and 0 when the condition 'equals' is selected, rather than detect them based on the existing data.

    Maybe, this is already possible?

    Any help is greatly appreciated. Chris

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @cj1005 ,

    This is possible but you are going to have to edit some of the conditions to do it. Take a look at the documentation here.

    You are going to want to change the init function slightly. The default for select elements can be found here. You're going to want to add a check when all of the options from the table have been added to see if your desired conditions are all present - if not declare them manually add them like the others.

    Thanks,
    Sandy

  • cj1005cj1005 Posts: 142Questions: 45Answers: 1

    Hi Sandy, thank you for your reply, good to know it is possible.
    I'll give it a go and let you know how I get on.
    Chris

Sign In or Register to comment.