Closed cihangll closed 4 years ago
Hi @cihangll,
Depending on the arguments that you're passing to SearchOptionsProcessor.Apply()
, I think the server-side part of JqueryDataTablesServerSide may be getting in the way of what you want. Are you passing an IQueryable<ItemTransfer>
?
If so, the SearchOptionsProcessor.Apply
method will be querying (searching) against the source ItemTransfer
type, not the projected ItemCardDataTableModel
type.
When the incoming datatables query parameters (JqueryDataTablesParameters
) are saying, "please search for the string 'Item Card' in the column named 'ItemType'", JQDT will produce a server-side expression like ItemTransfer.ItemType.Contains("Item Card")
.
Because ItemTransfer.ItemType
cannot be convinced to behave like a string, the exception appears.
In order to search by string on the ItemCardDataTableModel.ItemType
, you need to pass an argument of type IQueryable<ItemCardDataTableModel>
to SearchOptionsProcessor.Apply()
. This is also how you can achieve a search against a NameSurname
column.
Hi @chrisxh,
Thanks for the explanation.
Hi @cihangll,
Right now the package doest support enum type/custom type. I had a long thought of implementing this. I'll try to see if I can find a way to make this happen with attributes.
Thanks, Abdul
@cihangll, look at this enum filtering issue. Looks like if you configure your entity properly in efcore then enum filtering has to work. I'll try from my end and get back to you.
@cihangll If your using ef core why don't you try value converters for enum
properties? I'm focusing on asp.net core 3.0 upgrade. I'll try a sample after that.
@fingers10 Thank you for that. I'll try value converters for enum properties.
@cihangll , I tried with value converters. Looks like I need to define an extra attribute like [SearchableEnum(typeof(YourEnum))]
for that to work. I'll add this in the next release.
@cihangll but [SearchableEnum(typeof(YourEnum))]
will only allow eq
search. when I try co
Enum.TryParse<TEnum>
throws exception. This has this limitation. But for eq
case you enter the enum value with or without space Enum.TryParse<TEnum>
will succeed.
@fingers10 This is awesome. Thank you for this enhancement.
Hi Abdul,
How can i search custom property columns?
For example;
I have an enum in the entity model like this.
I want to search display name on the datatable but i am getting error like this;
Because UI property type is string and the entity property type is short.
Other Example;
I have a name and surname property in the entity model. I want to show Name + Surname => NameSurname column on the UI. How can i search this column?
Thanks.