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

Filter from html form

3 Answers 4 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Veteran
Dan asked on 18 Jan 2019, 08:18 PM

Hello, 

I have a grid that I would like to work with an html form.

 

Right now the form an grid work just fine. What i am trying to do is pass parameters to the method that runs the actual query. When I add in the parameters that is when the issue arises, instead of the results going back into the grid i get a page of json results. Any help would be greatly appreciated.  

 

@(Html.Kendo().Grid<MVCPROJECT.ViewModels.FormViewModel>()
                  .Name("SearchResultsGrid")
                  .Columns(columns =>
                  {
                      columns.Bound(c => c.FirstName).Width(120).Filterable(ftb => ftb.Multi(true));
                      columns.Bound(c => c.LastName).Width(120).Filterable(ftb => ftb.Multi(true));
                      columns.Bound(c => c.Agency).Width(120).Filterable(ftb => ftb.Multi(true));
                      columns.Bound(c => c.Address1).Width(120).Filterable(ftb => ftb.Multi(true));
                      columns.Bound(c => c.City).Width(120).Filterable(ftb => ftb.Multi(true));
                      columns.Bound(c => c.PhoneNumber).Width(130).Filterable(false);
                      columns.Bound(c => c.ServiceName).Width(150).Filterable(ftb => ftb.Multi(true));
                      columns.Bound(c => c.ClientType).Width(120).Filterable(ftb => ftb.Multi(true));
                  })
                  .NoRecords()
                  .Mobile()
                  .Pageable(pager => pager.PageSizes(new int[] { 10, 20, 50 }))
                  .Sortable()
                  .Filterable()
                  .Pageable(pager => pager.ButtonCount(5))
                  .Scrollable()
                  .Navigatable()
                  .HtmlAttributes(new { style = "height:550px;font-size:12px" })
                  .DataSource(dataSource => dataSource
                  .Ajax() 
                  .PageSize(20)
                  .Read(read => read.Action("SearchResults", "ProviderSearch"))
                  ))

 public ActionResult SearchResults([DataSourceRequest]DataSourceRequest request, string ClientType, int? ZipCode, int? Distance, string County, string[] ProviderServices)
        {
                return Json(GetSearchResults(ClientType).ToDataSourceResult(request));
        }

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 23 Jan 2019, 12:49 PM
Hi Dan,

I examined the code snippets, however I am not sure how the additional parameters are passed to the Read ActionMethod. By default submitting additional parameters can be done with the Data method. Check out the article below that describes the approach:

Would you try to pass the parameters this way and see how the behavior changes? In case the behavior persists please send us a runnable sample where the behavior is replicated. This will enable us to examine the issue locally and look for its cause.


Regards,
Viktor Tachev
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.
0
Dan
Top achievements
Rank 1
Veteran
answered on 23 Jan 2019, 03:48 PM

The additional parameter come from an HTML form, i have no issues getting them to the controller. 

when i use this return in my read action the data my grid properly shows on the page

return Json(GetSearchResults().ToDataSourceResult(request));

when I try to pass the ClientType to the GetSearchResults method I get a page of Json results 

return Json(GetSearchResults(ClientType).ToDataSourceResult(request));

 

I am trying to change the where clause query that is used to create the grid. My parameters come from the page to the GetSearchResults method. The query runs and i get the proper results. When the results are returned to the read method I am not sure what happens but instead of feeding into the grid i get returned to a page that shows my results

0
Tsvetomir
Telerik team
answered on 28 Jan 2019, 11:06 AM
Hi Dan,

Based on the provided information, a firm conclusion where does the issue stem from, cannot be provided. I have created a sample project which returns a sub-collection of records based on a parameter. 

Can you also ensure that there are no JavaScript errors present in the DevTools developer tools of the browser? There are occasions when a JavaScript error is thrown, the functionality of the Kendo UI widgets stops working as expected. Furthermore, in the Network tab of the DevTools, the server errors might be observed (if any).

If the issue persists, modify the attached sample and send it back to us. This would provide us the opportunity to investigate the case locally and provide accurate and clear-cut suggestions.


Best regards,
Tsvetomir
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.
Tags
Grid
Asked by
Dan
Top achievements
Rank 1
Veteran
Answers by
Viktor Tachev
Telerik team
Dan
Top achievements
Rank 1
Veteran
Tsvetomir
Telerik team
Share this question
or