I want to be able to enter numbers and the grid to filter numeric fields too according to those numbers. Enums would be nice too.
**Admin Edit**
The feature request will be researched and evaluated. It contradicts to our datasource filtering logic that relies on the type of the fields. Thus, it is highly possible that we will handle the task through a knowledge base example.
**Admin Edit**
Hello everyone,
Let me provide an update about this request.
A single textbox to search in multiple columns and data types raises questions about:
It's certain that different scenarios or users will require different behavior. At the same time, "be able to customize everything" is not optimal or even possible either.
The Grid already provides two filtering modes, which handle the standard use cases. So, the global search UI should be able to do something different and be flexible.
We implemented a Razor component for this multi-type search textbox. For the time being, the component is not built-in inside UI for Blazor, but you will still be able to reuse it and customize it. I have linked the code at the bottom of this post. We will appreciate everyone's feedback if the suggested behavior fits your use cases and requirements.
The component will do the following:
At this point, you only need to pass the filter descriptor to the Grid state.
The default behavior will be:
Here is the example with the reusable Razor component: Grid Knowledge Base: Search in Numeric Fields
Due to the ambiguous nature of this feature, we need to be very certain what do customers need and if it is practical to implement it.
I am setting the status of this thread as "Need more information" while gathering feedback. The information we receive from you will determine if we add a built-in feature to the Grid and how exactly.
So, we expect two types of comments now -
Regards,
Dimo
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
No need to overthink this.
Treat all numbers as integers. Dates, use the UI Culture.
For everything else add an option for a custom compare function.
Hi Marin,
having a default way to search in Non-String columns and being able to alter the behavior for special use-cases within an event-handler would be a good way to go.
Regards,
René
Hi René,
If automatic parsing becomes available, I'd imagine that the current culture would be used and the .TryParse method of double, but we are collecting this feedback, and maybe such features may become available. The thing about the "equals" check is that it's unclear whether it should be equals, less than or greater than - different cases will need it every which way.
I'm also thinking that the best flexibility would be achieved through an event that provides you the string value of the user input, and the filter descriptor the grid would build, so you could add to it or alter it as needed - you won't have to start from scratch to customize things. Would that be useful to you? It would, for example, let you add filters for fields that are not currently visible, which is not the default behavior of the searchbox for UX reasons.
Regards,
Marin Bratanov
Progress Telerik
Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).
Hello Marin,
if the searchbox contains more than something parsable to a date I would not display any results. That's why I would like to pass a list of valid formats. With that a date would have a clear definition so no guessing is needed.
For numbers I would like a "DecimalSeparator" and a "NumberEqualThreshold" Parameter.
I would then convert any Number (int/float/double/decimal) to double and do the following
if (Math.Abs(searchboxValue - columnValue) < NumberEqualThreshold) { // include in results }
Exposing an event for the searchbox for custom filter/search logic would not
help me much personally because then it would be more or less the same as
just keeping my custom implementation of a searchbox.
Hello René,
How would you solve the case where the searchbox contains more than something parsable to a date, assuming there is a list of such formats? How would numbers be handled, especially decimal values for integer columns? What would be the filter operator for such fields where a "contains" does not exist?
In another approach - would exposing an event for the searchbox so you can implement your own filtering be something that would help? It would let you parse the string in the desired fashion and add filters to the grid through its state for different fields depending on their type and your preferred logic.
Regards,
Marin Bratanov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hello Marin,
in our own implementation of a searchBox we do this for enums:
if(enumColumnValue.ToString().ToLowerInvariant().Contains(SearchString.ToLowerInvariant()))
{
// include in results
}
and this for dateTimes:
string[] validFormats = {"dd.MM.yyyy", "dd.MM.yy", "dd.MM.", "MM.yyyy", "MM.yy"};
var searchStringIsDate = DateTime.TryParseExact(SearchString?.ToLowerInvariant(),
validFormats,
System.Globalization.CultureInfo.InvariantCulture,
System.Globalization.DateTimeStyles.None,
out var date);
if(searchStringIsDate && d.WunschLiefertermin <= date)
{
// include in results
}
It would be great if a validDateTimeFormats Array could be configured for the searchBox and if a FilterLogicForDatTime Parameter could be set (we use seq but others could be needed as well).
Regards,
René
Hi all,
Do leave the types of data you want the searchbox to use, and I'd also appreciate some examples on the expected behavior for things that aren't strings - for example, what should be searched for enums, for dates (format?), separators for decimals values.
The issue here is that in that input the user writes an arbitrary string and there is no certain way to know what they want to filter on - how to know if it's a number or can it be a date (there are a myriad ways to write a date and its not feasible to try to parse the infinite amount of possible format strings).
Once this gets reviewed we will have the demand and we will be able to know what can and cannot be done.
What I can say at this point is that the Kendo searchbox also works with strings, try it in this dojo and type "9", for example: https://dojo.telerik.com/osoHijEV (screenshot attached at the end of this post). The same is listed for server operations in the UI for ASP.NET Core documentation and Blazor is always equivalent to server operations in that sense - it uses the same DataSourceRequest and DataSourceResult concepts that you'd use in the controller actions for that grid, and the same filter descriptor classes where a Contains operator is only possible for strings in .NET.
Regards,
Marin Bratanov
Progress Telerik
Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).
ASP.NET Core Grid supports searching on number fields - https://demos.telerik.com/aspnet-core/grid/search-panel
Hope Blazor Grid too supports searching on number fields in near future