Note that there are some explanatory texts on larger screens.

plurals
  1. POjqGrid fill up from stored procedure + SQL Server 2008 + MVC (without using model) -- Updated with sample code for better understanding
    text
    copied!<p>I want to fill jqGrid from a stored procedure, there was 1 good example is given at following link, but my problem is that I am not using model to retrieve data, any SOLUTION ?</p> <p>I am using jqGrid + SQL Server 2008 + ASP.net MVC3 (c#)</p> <p><a href="http://wyousuf.wordpress.com/2012/01/16/jqgrid-with-asp-net-mvc-and-ms-sqloracle-store-procedure/" rel="nofollow">Example of jqGrid filling by stored procedure with Model</a></p> <p>Here by am giving the code that i am using currently</p> <h1><strong>VIEW CODE</strong></h1> <pre><code>$(document).ready(function () { $('#History').jqGrid({ //url from wich data should be requested url: '@Url.Action("UploadData")?entity=' + getEntity(), //type of data datatype: 'json', //url access method type mtype: 'GET', //columns names colNames: ['ID', 'File','Uploaded', 'By'], //columns model colModel: [ { name: 'ID', index: 'ID', align: 'left', editable: false }, { name: 'File', index: 'File', align: 'left', editable: false, formatter: "text", width: '105px' }, { name: 'Uploaded', index: 'Uploaded', align: 'left', editable: false, formatter: "text", width: '102px' }, { name: 'By', index: 'By', align: 'left', editable: false, formatter: "text", width: '78px' }, ], //pager for grid pager: $('#Historypager'), //number of rows per page rowNum: 15, //initial sorting column sortname: 'File', //initial sorting direction sortorder: 'asc', //we want to display total records count viewrecords: true, //Sets the caption for grid caption: 'Upload History', //grid height height: '100%' }); $('#History').jqGrid('navGrid', '#Historypager', { add: false, del: false, edit: false, search: false }); $('#History').jqGrid('hideCol', "ID"); var dialogPosition = $(this).offset(); }); </code></pre> <h1><strong>CONTROLLER METHOD</strong></h1> <pre><code>public JsonResult UploadData(string sidx, string sord, int page, int rows, string entity) { int pageIndex = Convert.ToInt32(page) - 1; int pageSize = rows; var entitytype = Request.QueryString["entity"].ToString().Trim(); var uploadlist = objEntities.Uploads.Where(u =&gt; u.TableName == entitytype).ToList().AsQueryable(); // fetches the data from upload table int totalRecords = uploadlist.ToList().Count(); // total records in the current table int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize); // counts the total no. of pages if (sord.Trim().ToLower() == "asc") // fetches data according the sorting order uploadlist = uploadlist.OrderBy(x =&gt; TypeHelper.GetPropertyValue(x, sidx)).Skip(pageIndex * pageSize).Take(pageSize); else uploadlist = uploadlist.OrderByDescending(x =&gt; TypeHelper.GetPropertyValue(x, sidx)).Skip(pageIndex * pageSize).Take(pageSize); // fetches data and sets it in JSON format var jsonData = new { total = totalPages, page = page, records = totalRecords, rows = (from b1 in uploadlist select new { id = b1.ID, cell = new string[] { Convert.ToString(b1.ID), b1.File, Convert.ToString(b1.Uploaded), Convert.ToString(b1.By) } }).ToArray() }; return Json(jsonData, JsonRequestBehavior.AllowGet); // returns the data back to the jqgrid } </code></pre> <p>In this Example i've used LINQ demo, but now in new task i've to use Stored Procedure to fetch the data...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload