无法在MVC 4中绑定jtable [英] Unable to bind jtable in MVC 4

查看:52
本文介绍了无法在MVC 4中绑定jtable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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>





我尝试过:



谷歌,论坛,jquery帮助和其他很多



What I have tried:

google ,forums ,jquery help and others lot

推荐答案

('#PersonTableContainer')。jtable({
title:'人员表',
行动:{
listAction:'/ Department / DeptList',
// createAction:'/ Test / Index3',
// updateAction:'/ GettingStarted / UpdatePerson',
// deleteAction:'/ GettingStarted / DeletePerson'
},
字段:{
_DepartmentID:{
key:true,
list:false
},
_Department:{
title:'Author Name',
width:'40%'
},
_缩写:{
标题:'年龄',
宽度:'20%'
},
_prefix:{
title:'记录日期',
宽度: '30%',

},
_DeptInchargeID:{
title:'记录日期',
宽度:'30%',

}
}
});
('#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');

}
函数showDiv(){
('#PersonTableContainer').jtable('load'); } function showDiv() {


('#MailingContactDetails')。show(1000)
}
函数showDiv2(){
('#MailingContactDetails').show(1000) } function showDiv2() {


这篇关于无法在MVC 4中绑定jtable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆