J Antoni

J Antoni

  • NA
  • 81
  • 35.8k

Gridmvc.html on click- paging or sorting to hit HttpPost

Aug 29 2017 11:29 PM
I have a GridMvc.Html in my web app.
My Requirement
On Click of the Paging\Sorting functionality I want it to hit HttpPost Action Method.
Currently it hits only HttpGet .
I have tried using jQuery, it doesn't work and I am not sure on it too.

This is my Grid in the View
 
  1. @Html.Grid(Model.SignalDataList).Columns(columns =>  
  2. {  
  3.     columns.Add(s => s.SignalName).Titled("Name");  
  4.     columns.Add(s => s.TimeReceived).Titled("Time Received").Filterable(true);  
  5.     columns.Add(s => s.Value).Titled("Value").Filterable(true);  
  6.    
  7. }).WithPaging(10).Sortable(true)  
 Each click on grid (page\Sort column) goes to HttpGet . So the data I have selected\filtered via DropDown cannot be handled.
 
Below is my Action Method.The clicks  on MVC.Grid hits the below Action method only. The selected data in the DropDown\TextBox is not visible in this method.
 
  1. [HttpGet]
  2. public ActionResult AlarmSignalData()  
  3.     {  
  4.         SignalDataRepository signalDb = new SignalDataRepository();  
  5.         ...  
  6.         try  
  7.         {  
  8.            GetData();  
  9.         }  
  10.         catch(Exception ex) { return View("Error"new HandleErrorInfo(ex, "SignalData""AlarmSignalData")); }  
  11.         return View(signalDataView);  
  12.     }  
 
 So I want it to hit HttpPost , coz I want to process selected data in trextbox\DropDownList in my View . In HttpPost Action Method I pass my model, from where I can take the TextBox\DropdownList values to fetch filtered data using method GetData(model.SelectSignal,model.FromDate,model,ToData); in the code below
  1. [HttpPost]  
  2. public ActionResult AlarmSignalData(Model model)  
  3.     {  
  4.         SignalDataRepository signalDb = new SignalDataRepository();  
  5.         ...  
  6.         try  
  7.         {  
  8.            GetData(model.SelectSignal,model.FromDate,model,ToData);  
  9.         }  
  10.         catch(Exception ex) { return View("Error"new HandleErrorInfo(ex, "SignalData""AlarmSignalData")); }  
  11.         return View(signalDataView);  
 What I have tried:

I have tried using jQuery, to handle via on click of the div which contains the Grid MVC it doesn't work and I am not sure on it too.
 

Answers (1)