I am using jqgrid on EF4 MVC3 (C#). I based search on this @Oleg 's solution, which works fine and fits for my needs.
I have the following columns defined in my grid:
...
{ name: 'Stato', index: 'StatoTicketID', width: 20, align: 'left', sorttype: 'int', searchoptions: { sopt: ['eq']} },
{ name: 'StatoTicketID', index: 'StatoTicketID', width: 20, align: 'left', sorttype: 'int', hidden: true, searchoptions: { sopt: ['eq']} },
...
As you can see, the column Stato
is ordered by the index StatoTicketID
(hidden integer field) and ordering works fine.
PROBLEM
When I try to search a value of Stato
, the filter is passed on index StatoTicketID
as string, while I'd like to search by Stato
values. So I get an exception inside the controller which specifies that I cannot convert String type to Int32.
Does exist a way to specify on which column apply search, when index is on a different column, like in my case?
EDIT & WORKAROUND: For now I solved my problem with the following workaround.
(inside foreach (Rule rule in rules) of FilterObjectSet by Oleg)
....
if (rule.field == "StatoTicketID")
{
rule.field = "StatoTicket.Stato";
propertyInfo = typeof(T).GetProperty("stringfield"); // where stringfield is a text type column of my model
}
I realize very well that is not an elegant solution, I expect a kind response by you, to know how to implement the required behaviour directly from jqGrid, please.
Thanks in advance