Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i write certain piece of code using  mvc 4 and jquery and jtable ,but data is not visible in grid ,only blank grid is present , (No data available!) although i have updated all references of jquery in vs 2012 ,  action method is showing 3 records at quick watch but not showing in grid any help

here is view  action method

       [HttpPost]
            public JsonResult DeptList()
            {

                try
                {
                    List<TBL_Department> persons = new List<TBL_Department>
            {
                new TBL_Department{DepartmentID=1,Department="Aaa",Abbreviation="a",prefix="AR",DeptInchargeID=2},
                new TBL_Department{DepartmentID=2,Department="Bbb",Abbreviation="b",prefix="AR",DeptInchargeID=2},
                new TBL_Department{DepartmentID=3,Department="Ccc",Abbreviation="c",prefix="AR",DeptInchargeID=2}
            };
                    return Json( persons, JsonRequestBehavior.AllowGet);
                }
                catch (Exception ex)
                {
                    //return Json(new { Result = "ERROR", Message = ex.Message });
                    return Json(new { Result = ex.ToString(), Message = ex.Message });
                }
                //try
                //{
                //      var data1 =  Models.TBL_Department.GetAlldept();
                //      return Json(new { Result = "OK", Records = data1 });
                //}
                //catch (Exception ex)
                //{
                //    return Json(new { Result = "ERROR", Message = ex.Message });
                //}
            }


    <script>

        function GetFilter() {
           alert("fdgdf")
          

            $('#PersonTableContainer').jtable({
                title: 'Table of people',
                actions: {
                    listAction: '/Department/DeptList',
                    // createAction: '/Test/Index3',
                    // updateAction: '/GettingStarted/UpdatePerson',
                    //  deleteAction: '/GettingStarted/DeletePerson'
                },
                fields: {
                    _DepartmentID: {
                        key: true,
                        list: false
                    },
                    _Department: {
                        title: 'Author Name',
                        width: '40%'
                    },
                    _Abbreviation: {
                        title: 'Age',
                        width: '20%'
                    },
                    _prefix: {
                      title: 'Record date',
                       width: '30%',
                   
                    },
                    _DeptInchargeID: {
                           title: 'Record date',
                           width: '30%',

                    }
                }
            });
            $('#PersonTableContainer').jtable('load');

        }
        function showDiv() {

            $('#MailingContactDetails').show(1000)
        }
        function showDiv2() {

            $('#AccountDetail').show(1000)
        }

    </script>


What I have tried:

google ,forums ,jquery help and others lot
Posted
Updated 20-Nov-17 17:15pm

1 solution

remove the underscore in the field names and try

fields: {
                   DepartmentID: {
                       key: true,
                       list: false
                   },
                   Department: {
                       title: 'Author Name',
                       width: '40%'
                   },
                   Abbreviation: {
                       title: 'Age',
                       width: '20%'
                   },
                   _prefix: {
                     title: 'Record date',
                      width: '30%',

                   },
                   DeptInchargeID: {
                          title: 'Record date',
                          width: '30%',

                   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900