erummirza Ответов: 1

Не удается выполнить привязку jtable, выполните следующие действия в MVC 4


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>


Что я уже пробовал:

google ,форумы ,помощь jquery и другие много

1 Ответов

Рейтинг:
0

Karthik_Mahalingam

снимите крышку underscore в поле имена и попробуйте

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%',

                   }