Note that there are some explanatory texts on larger screens.

plurals
  1. POJQgrid Sorting MVC3
    primarykey
    data
    text
    <p>In my CS page i have following code </p> <pre><code> public JsonResult DynamicGridData(string sidx, string sord, int page, int rows) { Employee _emp = new Employee(); List&lt;Employee&gt; _lstemp = _emp.GetallEmp(); int pageIndex = Convert.ToInt32(page) - 1; int pageSize = rows; int totalRecords = _lstemp.Count(); int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize); var jsonData = new { total = totalPages, page, records = totalRecords, rows = ( from emp in _lstemp select new { i = emp.ID, cell = new string[] { emp.ID.ToString(), emp.FirstName.ToString(), emp.LastName.ToString(),emp.Age.ToString(),emp.State.ToString(),emp.Country.ToString() } }).ToArray() }; return Json(jsonData); } </code></pre> <p>My Model Is</p> <pre><code> public class Employee { public int ID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public int Age { get; set; } public string State { get; set; } public string Country { get; set; } public List&lt;Employee&gt; GetallEmp() { List&lt;Employee&gt; list = new List&lt;Employee&gt;() { new Employee{ID=1,FirstName="Asish",LastName="Nehra",Age=25,State="A",Country="India"}, new Employee{ID=2,FirstName="Nsish",LastName="Oehra",Age=35,State="B",Country="Sri Lanka"}, new Employee{ID=3,FirstName="Psish",LastName="Lehra",Age=26,State="C",Country="Bangladesh"}, new Employee{ID=4,FirstName="Jsish",LastName="Hehra",Age=25,State="D",Country="Australia"}, new Employee{ID=5,FirstName="Usish",LastName="Tehra",Age=85,State="E",Country="Kenya"}, new Employee{ID=6,FirstName="Rsish",LastName="Lehra",Age=15,State="F",Country="India"}, new Employee{ID=7,FirstName="Isish",LastName="Eehra",Age=5,State="G",Country="Pakistan"}, new Employee{ID=8,FirstName="Asish",LastName="Nehra",Age=25,State="A",Country="India"}, new Employee{ID=9,FirstName="Nsish",LastName="Oehra",Age=35,State="B",Country="Sri Lanka"}, new Employee{ID=10,FirstName="Psish",LastName="Lehra",Age=26,State="C",Country="Bangladesh"}, new Employee{ID=11,FirstName="Jsish",LastName="Hehra",Age=25,State="D",Country="Australia"}, new Employee{ID=12,FirstName="Usish",LastName="Tehra",Age=85,State="E",Country="Kenya"}, new Employee{ID=13,FirstName="Rsish",LastName="Lehra",Age=15,State="F",Country="India"}, new Employee{ID=14,FirstName="Isish",LastName="Eehra",Age=5,State="G",Country="Pakistan"}, new Employee{ID=15,FirstName="Asish",LastName="Nehra",Age=25,State="A",Country="India"}, new Employee{ID=16,FirstName="Nsish",LastName="Oehra",Age=35,State="B",Country="Sri Lanka"}, new Employee{ID=17,FirstName="Psish",LastName="Lehra",Age=26,State="C",Country="Bangladesh"}, new Employee{ID=18,FirstName="Jsish",LastName="Hehra",Age=25,State="D",Country="Australia"}, new Employee{ID=19,FirstName="Usish",LastName="Tehra",Age=85,State="E",Country="Kenya"}, new Employee{ID=20,FirstName="Rsish",LastName="Lehra",Age=15,State="F",Country="India"}, new Employee{ID=21,FirstName="Isish",LastName="Eehra",Age=5,State="G",Country="Pakistan"}, }; return list; } } </code></pre> <p>In my Cshtml page </p> <pre><code>&lt;script type="text/javascript"&gt; jQuery(document).ready(function () { jQuery("#list").jqGrid({ url: '/Home/DynamicGridData/', datatype: 'json', mtype: 'POST', colNames: ['ID', 'FirstName', 'LastName', 'Age', 'State', 'Country'], colModel: [ { name: 'ID', index: 'ID', width: 40, align: 'left' }, { name: 'FirstName', index: 'FirstName', width: 80, align: 'left' }, { name: 'LastName', index: 'LastName', width: 80, align: 'left' }, { name: 'Age', index: 'Age', width: 80, align: 'left' }, { name: 'State', index: 'State', width: 80, align: 'left' }, { name: 'Country', index: 'Country', width: 80, align: 'left' }], pager: jQuery('#pager'), rowNum: 10, rowList: [10, 20, 30], sortname: 'ID, FirstName, LastName, Age, State, Country', sortorder: "Asc", viewrecords: true, imgpath: '/content/images', autowidth: true, width: '100%', height: '100%', multiselect: false, caption: "Grid example", loadComplete: function() { //jQuery("#myGridID").trigger("reloadGrid"); // Call to fix client-side sorting } }); //jQuery("#list").jqGrid('navGrid', '#pager', { add: true, edit: true, del: true }); jQuery("#list").jqGrid('navGrid', '#pager', { edit: false, add: false, del: false }, {}, {}, {}, { multipleSearch: true, multipleGroup: true, showQuery: true }); }); &lt;/script&gt; </code></pre> <p>How can i sort all the columns..I just want to sort all my fields by making sortable:true for all fields</p> <p><strong>EDIT</strong> The <code>&lt;script&gt;</code> was not correct formatted</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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