Forum
18:53
23/12/2013
I posted this on here http://stackoverflow.com/quest.....ading-data
Am new to JQGrid. I set up the grid following the examples given here using the Html JQGrid helper class under my view. Trirand MVC - JQGrid
from the example - it has 2 functions in the controller, first one is ActionResult PerformanceLinq() - which is just returning the view. second one is JsonResult DataRequested() - this returns the data in jqgrid model: return gridModel.OrdersGrid.DataBind(northWindModel.Orders);
So, I have all my data loaded perfectly, rendered. Done as far as the first step.
I have a textbox, and a search button (they both aren't JQGrid components). onclick event should trigger an ajax call to DataRequested() method, which I modified a bit passing a parameter. How can I refresh myGrid without rendering the page again?
function GetAccountSearchGrid() { debugger; var myKey = document.getElementById('SearchKey').value; //this is searchKey value $.ajax({ url: '@Url.Action("AccountSearchGridDataRequest")', type: 'GET', data: { id: myKey }, dataType: 'json', contentType: 'application/json', success: function (data) { jQuery('AccountSearchGrid1').jqGrid('clearGridData'); jQuery('AccountSearchGrid1').jqGrid('setGridParam', { data: data }); jQuery('AccountSearchGrid1').trigger('reloadGrid'); //$('#AccountSearchGrid1').jqGrid('setGridParam', { data: data }).trigger('reloadGrid'); //jQuery("#AccountSearchGrid1")[0].p.data = data; }, error: function (data) { alert("error"); } }); }
Please keep in mind that AccountSearchGridDataRequest(searchKey) returns a gridmodel
- so how can I bind the JsonResult into the grid, in Ajax success inline?
here's my c# controller code for getting the datapublic JsonResult AccountSearchGridDataRequest(string id) { JobDefinitionContact jc = new JobDefinitionContact(); if (!String.IsNullOrEmpty(id)) { jc.CompanyName = id; } var jobDefServiceClient = new JobDefServiceClient(); var acctSearchResult = from i in jobDefServiceClient.GetAccountSearch(jc, "100") select i; IQueryable<JobDefinitionContact> searchItems = acctSearchResult.AsQueryable<JobDefinitionContact>(); var gridModel = new JobDefinitionAccountSearchGridModel(); SetUpGrid(gridModel.AccountSearchGrid, id); return gridModel.AccountSearchGrid.DataBind(searchItems); }
21:58
23/12/2013
here's how I reload it without calling $.ajax - i read through http://www.trirand.com/jqgridw.....ki:methods
jQuery("#AccountSearchGrid1").jqGrid('setGridParam', { url: "JobDefinition/AccountSearchGridDataRequest/?id=" + myKey, page: 1 }).trigger('reloadGrid');
So, please let me know if there is a better approach to this solution. And still I would like to know how to reload it under success inline in ajax call.
thanks.
Most Users Ever Online: 715
Currently Online:
37 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66