jQuery UI Widgets › Forums › Plugins › Data Adapter › jqxGrid Data Adapter with MVC Stored Procedure
Tagged: ajax, jqxgrid, MVC, SP, StoredProcedure
This topic contains 1 reply, has 1 voice, and was last updated by soojung 8 years, 6 months ago.
Viewing 2 posts - 1 through 2 (of 2 total)
-
Author
-
Hello. I’m using ASP.NET MVC pattern calling data from Stored Procedure. I get that data with ajax, then trying to adjust adapter with jqxGrid. If I do this, it just draw grid line and show no data… What is problem? Here is my code.
c#
public ActionResult RefreshData(string saupcode, string branchcode) { using (var ctx = new UserDBContext()) using (var cmd = ctx.Database.Connection.CreateCommand()) { ctx.Database.Connection.Open(); cmd.CommandText = "EXEC AGENT_SEL '" + saupcode + "', '" + branchcode +'"; // 0.SaupCode, 1.SaupName, 2.BranchCode, 3.BranchName, 4.AgentCode, 5.AgentName, 6.BusinessCode, 7.ModemNo, 8.UseFlag, 9.IDate, 10.UDate, 11.LastRecvDate using (var reader = cmd.ExecuteReader()) { var model = clsDBHandler.Read(reader).ToList(); var result = new { querydata = model }; return Json(result, JsonRequestBehavior.AllowGet); } } }
javascript
$(function () { var saupCode = "00", branchCode = "000"; var Gridsource = { dataType: "json", mtype: 'GET', datafields: [ { name: 'SaupName'}, { name: 'BranchName'}, { name: 'AgentCode'}, { name: 'AgentName'} ], url: '/RegAgent/RefreshData/', data: { saupcode: saupCode, branchcode: branchCode } }; var dataAdapter = new $.jqx.dataAdapter(Gridsource, { loadComplete: function (records) { var alldata = records.querydata, dataLen = alldata.length, rowdata = new Array(); for (var i = 0; i < 10; i++) { var row = new Array(); var oneData = alldata[i] + ''; var a_splitData = oneData.split(','); row["SaupName"] = a_splitData[1]; row["BranchName"] = a_splitData[3]; row["AgentCode"] = a_splitData[4]; row["AgentName"] = a_splitData[5]; rowdata[i] = row; } return row; } }); $("#jqxgrid").jqxGrid({ source: dataAdapter, theme: 'darkblue', width: 800, columns: [ { text: 'SaupName', width: 100, datafield: 'SaupName'}, { text: 'BranchName', width: 100, datafield: 'BranchName'}, { text: 'AgentCode', width: 100, datafield: 'AgentCode', cellsformat: 'n2'}, { text: 'AgentName', width: 100, datafield: 'AgentName', cellsformat: 'n2'} ] }); });
Sorry, I did mistake getting sp data… I solved.
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.