Approved
Last Updated: 26 Apr 2019 10:16 by ADMIN
Chris
Created on: 17 Apr 2019 00:45
Category: Grid
Type: Feature Request
2
Filter on Array column with multi-select

I was wanting to create a multiselect filter inside the kendo grid that will filter an array column, NOT a simple string column.  Just adding the .Filterable(ftb => ftb.Multi(true)) does display a basic 'multiselect' with just checkboxes in it, which is not ideal , but does work.  But, when you click filter, the grid becomes empty.  I had to use a clienttemplate() function, to return an html object like so:

export function MultiRowTemplate(data) {
       if (data == null) {
           return "";
       }
       var row = "";
       for (var i = 0, len = data.length; i < len; i++) {
           row += data[i].Description + "<br/>";
       }
       return row;
   }

 

My column is:

columns.ForeignKey(a => a.DisplayExp, (System.Collections.IEnumerable)ViewData["Exp"], "Id", "Description").ClientTemplate("#= MultiRowTemplate(data.DisplayExp) #").Filterable(ftb => ftb.Multi(true)).Title("Experience");

 

the code for the foreign key doesn't make much sense as it's an array column, but that was pointed to by telerik support on other forum posts.  

So, there must be a way to hook into that column and run some custom code to return to the grid the filtered values?  i've seen examples for jquery, and mvc, but theres nothing for .net core.  This should just work out of the box, as I don't think this is an uncommon need.  Could you give me an example or point me in the right direction?

 

 

 

 

3 comments
ADMIN
Preslav
Posted on: 26 Apr 2019 10:16
Hello,

At this stage, data operations over an array are not part of the built-in functionality. Thus, this forum post is converted to a feature request.


Regards,
Preslav
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Chris
Posted on: 23 Apr 2019 19:49
Thanks for all the examples.  I have looked them over, and they don't apply to filtering on the column using a Multi-Select, and they do not apply to .NET core.  The example was for Jquery.  I don't need to rewrite my code to get it to filter.  this should work out of the box, but it doesn't.  So, I need a full working example in .NET core, that filters using a multiselect.  Also, the reason why I used a foreign key is, that I can never get the filters in a multiselect to actually appear without it.  I managed to get it going myself using the foreign key and serverside filtering.  But, it only works on one column which is not good at all.  So, I need a full working example using .NET core.  I don't need any examples using Jquery, or editing using multi-select, as that is not relevant.
ADMIN
Alex Hajigeorgieva
Posted on: 19 Apr 2019 14:29
Hello, Chris,

Thank you for the code snippet. I can see that you have also submitted a private support thread and just like my colleague I would need some more information.

It is unclear to me why a Foreign Key column is used. If the column type is actually an array, you should bind it as an array. We have an example with models that contain collections or ASP.NET Core:

https://github.com/telerik/ui-for-aspnet-core-examples/tree/master/grid/multiselect-as-editor
https://github.com/telerik/ui-for-aspnet-core-examples/tree/master/grid/listbox-as-editor

As far as the custom filtering UI is concerned, the column points to a JavaScript function so you can replace the body of the function with the example for jQuery Kendo UI:

.Filterable(filterable => filterable.UI("cityFilter"))

https://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/filtering/multiselect-used-for-column-filtering

Finally, it is best to choose a single thread to continue the conversation so that the thread is focused in a single place and we do not miss anything. If you like you can continue the communication in the private support thread and we can subsequently update this forum thread when a resolution is reached.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.