locked
jqgrid in .net core shows empty rows RRS feed

  • Question

  • User-1202579601 posted

    public IActionResult GetData(string sidx, string sord, int page, int rows)

    { int pageIndex = Convert.ToInt32(page) - 1;

    int pageSize = rows;

    var Certificate2 = _context.Certificates .Where(c => (c.Status == true)) .OrderBy(c => c.CertificateType) .ThenByDescending(c => c.Dop) .AsNoTracking();

    int totalRecords = Certificate2.Count();

    var totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows);

    var jsonData2 = new { total = totalPages, page, records = totalRecords, rows = Certificate2 };

    return Json(jsonData2); }

    //script file

    $(document).ready(function () { $("#jqGrid1").jqGrid({

    url: "/Certificates/GetData",

    datatype: "json",

    jsonReader: { total: "total", page: "page", records: "records", root: "rows", repeatitems: false },

    autowidth: true, multiselect:false,

    emptyrecords: 'No records to display',

    mtype:'GET',

    colModel: [ { label: 'Certificate Type', name: 'CertificateType', width: 75, editable: true, edittype: "select", editoptions: { value: "1:Workshop;2:Fdp;3:Symposium;4:Others" }, editrules: { required: true } },

    { label: 'Date', name: 'Dop', width: 90, editable: true, edittype: "text", formatter: 'date', formatoptions: { newformat: 'd/m/Y' }, editoptions: { dataInit: function (element) { $(element).datepicker({ id: 'Dop_datePicker', //dateFormat: 'M/d/yy', //minDate: new Date(2010, 0, 1), maxDate: new Date(2020, 1, 1), showOn: 'focus' }); } }, editrules: { required: true } },

    { label: 'Interval', name: 'Interval', width: 50, editable: true, edittype: "text", editrules: { required: true }}, { label: 'Venue', name: 'Venue', width: 80, editable: true, edittype: "text", editrules: { required: true } },

    { label: 'Event', name: 'Event', width: 80, editable: true, edittype: "text", editrules: { required: true } } ],

    viewrecords: true, // show the current page, data rang and total records on the toolbar width: 580, height: 200, rowNum: 30, loadonce: true, sortorder: "asc", // this is just for the demo pager: "#jqGridPager1", rowList: [10, 20, 30, 40, 50] });

    In controller- Getdata method is showing records  in jsondata2 successfully. Accordingly jqgrid shows 4 empty rows. Column models label

    is also shown but empty rowcells.

    Monday, November 16, 2020 2:16 PM

All replies

  • User1312693872 posted

    Hi,pmdrait

    This post was not approved that day, and I'm sorry for the delay. Have you solved your problem now? I noticed that you have another post which

    could have included this question and you may solved this problem by that post.

    If you still have this problem, could you please send the picture again (I can't load it) and share the related code in a better manner? 

    Best Regards,

    Jerry Cai

    Friday, December 4, 2020 9:12 AM
  • User-1202579601 posted

    I have not found the solution so far. jqgrid is able to display the records from controller, but unable to route to edit/delete.create post

    method, it i searching for cshtml file. I tried from more than 3 controllers, no change. how to debug the navgrid part. problem is in

    suspended state.

    Can we get the crud demo using view components as alternative

    Friday, December 4, 2020 1:06 PM