≡

Restrict Search condition in Column Control

Restrict Search condition in Column Control

sarooptrivedisarooptrivedi Posts: 68Questions: 20Answers: 2

I have Bool type column where value is true or false. Is that any way I can restrict the Column control search condition dropdown with only equal and does not equal

Replies

  • allanallan Posts: 66,144Questions: 1Answers: 11,028 Site admin

    Yes, in the searchNumber configuration object you can specify an excludeLogic option, to have it remove whatever options you don't want.

    Allan

  • sarooptrivedisarooptrivedi Posts: 68Questions: 20Answers: 2

    @allan : the Boolean column is considering the text in the datatables.net

    if I type true or false it is throwing the exception from bool to char type exception. I change the search condition, but I need to limit the search to equal and not equal.

  • allanallan Posts: 66,144Questions: 1Answers: 11,028 Site admin

    Ah - I see. I'm thinking it might be best to add a new searchBoolean content type to ColumnControl. Perhaps a boolean renderer to DataTables core as well.

    One thing - when you say that you are getting an error, are you using server-side processing with this? Are you using the .NET server-side libraries perhaps?

    Allan

  • sarooptrivedisarooptrivedi Posts: 68Questions: 20Answers: 2
    edited October 22

    Yes I am using the .NET libraries.

    I change the Request.Form before I send to the Editor to process the response. So Until the user type whole true or false the value of search always be empty string. which is help to handle the error. The error I receive. This is the common issue for the serverside for searchBuilder and SearchPane for boolean type search

    Conversion failed when converting the nvarchar value 't' to data type bit.

    ` if (string.Equals(f.Value.ToString(), "text", StringComparison.OrdinalIgnoreCase))
              {
                  // Derive the corresponding value key by replacing the trailing [type] with [value]
                  var valueKey = key.Replace("[type]", "[value]");
    
                  if (dictValues.TryGetValue(valueKey, out var existing))
                  {
                      var sval = existing.ToString();
                      if (string.Equals(sval, "true", StringComparison.OrdinalIgnoreCase))
                      {
                          dictValues[valueKey] = "1";
                      }
                      else if (string.Equals(sval, "false", StringComparison.OrdinalIgnoreCase))
                      {
                          dictValues[valueKey] = "0";
                      }    // Treat empty as not-a-number; if it's not a valid number, replace with empty
                      else if (!Boolean.TryParse(sval, out _))
                      {
                          dictValues[valueKey] = StringValues.Empty;
                      }
                  }
              }`
    
  • allanallan Posts: 66,144Questions: 1Answers: 11,028 Site admin

    Agreed - a proper boolean type search type will address that. I'll get onto that early next week.

    Allan

  • allanallan Posts: 66,144Questions: 1Answers: 11,028 Site admin

    I've just made this commit to DataTables core to add a boolean rendering helper.

    I've put it on a 3.3 branch for the moment. I might merge it to master - it depends on a couple of other ideas I have for what might go into 3.3. I'll carry this work on next week:

    • A new boolean search type for ColumnControl
    • Addressing issues with the server-side libraries.

    Allan

Sign In or Register to comment.