This is a migrated thread and some comments may be shown as answers.

Filter Multi Checkboxes Unique AJAX

1 Answer 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ed
Top achievements
Rank 1
Ed asked on 05 Jun 2015, 07:25 PM

In my grid, I'm working on Filter Multi Checkboxes. In the unique ajax call, I would like to return a simple array of strings, like the following:

data.OrgSelections.Select(o => o.CompanyName).Distinct().ToList()

But the js is expecting a full on data structure, e.g. with an array of {CompanyName: "Susie's Seashell Shop"}

When I look at the demo and the ajax response, it seems to be unnecessarily heavy with data that will never be used for the purpose of showing the distinct items (all other columns in the view model are included, complete with data). In other words, all the Unique ajax call should be interested in is the unique set of strings for the checkboxes, so why can't it just accept an array of strings?  Or.. is there a way to configure it to accept a simple array of strings and I just haven't found it yet? Or, is there a reason why you may need to send down the complete ViewModel data structure that I'm not yet realizing?

OK, so, I'm assuming (for the purpose of this post and in the interest of getting something working in the short term) there may not be a way to just send down a simple array of strings. How can I convert the above code to return an array of anonymous types with a single field, CompanyName? I know this is more of a generic C# question, but I'm drawing a blank right now.

Thanks,

--Ed

1 Answer, 1 is accepted

Sort by
0
Ed
Top achievements
Rank 1
answered on 05 Jun 2015, 07:35 PM
data.OrgSelections.Select(o => new { o.CompanyName }).Distinct().ToList()
Tags
Grid
Asked by
Ed
Top achievements
Rank 1
Answers by
Ed
Top achievements
Rank 1
Share this question
or