joeharrison714 / MVCGrid.Net

http://mvcgrid.net
MIT License
74 stars 55 forks source link

Filter parameters aren't passed through the query string correctly #17

Closed biclon closed 7 years ago

biclon commented 9 years ago

Issue:

When I apply a filter, the query string is populated with the name of my text box, rather than the name of my filter specified in the data-mvcgrid-option attribute. This resulted in duplicate query string parameters being passed to the server and my query string looking like:

?FromDate=SomeDate&fromdate=SomeDate

Sample View Code:

@Html.TextBoxFor(x => x.FromDate, new { @class = "form-control", @placeholder = "From", @id = "FromDate",@Name="fromdate",@data_mvcgrid_option="FromDate", @data_mvcgrid_type="filter" })

Sample Grid Builder Code:

cols.Add("FromDate") .WithHeaderText("From Date") .WithFiltering(true) .WithValueExpression(x => x.CreatedDateTime.Value.ToShortDateString());

Sample Data Retrieval Filter

.WithFiltering(true) .WithRetrieveDataMethod(context => { context.QueryOptions.GetFilterString("ToDate"); ...

Workaround:

I was able to get around this issue by specifying the name of the input box, in lowercase, to match the value of the data-mvcgrid-option attribute.

joeharrison714 commented 9 years ago

I attempted to reproduce the issue here: http://mvcgrid.net/Test/DisplayGrid/Issue17Grid

Currently, it is behaving normally. Can you let me know what else I need to do to cause the error?

biclon commented 9 years ago

I attempted to reproduce the issue using the existing source code that I had the issue with. I wasn't able to reproduce the issue. The only reason why I wasn't able to reproduce it is because I've since refactored my grid definition. I believe it may have been an issue on my end, not yours. If the issue appears at a later time then I will provide another update.