ASP.NET MVC 3& jTable-初学者的问题 [英] ASP.NET MVC 3 & jTable - a begginer's question

查看:70
本文介绍了ASP.NET MVC 3& jTable-初学者的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
尽管我对vb.net有严格的了解,但我还是ASP.NET的新手,我刚刚读过这篇文章

Hello,
I''m new to ASP.NET though I have a rigid vb.net understanding, I''ve just read this article AJAX based CRUD tables using ASP.NET MVC 3 and jTable jQuery plug-in[^]
and if I could implement it, I''ll finish my project in hours...

but..

here is my code and all I get is a blank page, and the UserList() function isn''t called at all.

DemoController.vb

Public Class DemoController
        Inherits System.Web.Mvc.Controller

        Private db As New LernJTableEntities

        '
        ' GET: /Demo

        Function Index() As ActionResult
            Return View()
        End Function

        <HttpPost()>
        Function UserList(Optional jtStartIndex As Integer = 0, Optional jtPageSize As Integer = 0, Optional jtSorting As String = Nothing) As JsonResult
            Try
                'Get data from database
                Dim UserCount = db.User.Count
                 Dim Users As New List(Of User)(db.User.Skip(jtStartIndex).Take(jtPageSize))

                'Return result to jTable
                Return Json(New With {.Result = "OK",
                                      .Records = Users,
                                      .TotalRecordCount = UserCount})
            Catch ex As Exception
                Return Json(New With {.Result = "ERROR",
                                      .Message = ex.Message})
            End Try
        End Function

        <HttpPost()>
        Function DeleteUser() As JsonResult

        End Function

        <HttpPost()>
        Function UpdateUser() As JsonResult

        End Function

        <HttpPost()>
        Function CreateUser() As JsonResult

        End Function



    End Class



Index.vbhtml



Index.vbhtml

@Code
    ViewData("Title") = "Users"
End Code

<div id="UserTableContainer">
</div>

<script type="text/javascript">

    $(document).ready(function () {

        $('#UserTableContainer').jtable({
            title: 'User List',
            paging: true,
            pageSize: 10,            
            actions: {
                listAction: '@Url.Action("UserList")',
                deleteAction: '@Url.Action("DeleteUser")',
                updateAction: '@Url.Action("UpdateUser")',
                createAction: '@Url.Action("CreateUser")'
            },
            fields: {
                UserId: {
                    key: true,
                    create: false,
                    edit: false,
                    list: false
                },
                Name: {
                    title: 'Name',
                    width: '100%'
                }                
            }
        });

        //Load user list from server
        $('#UserTableContainer').jtable('load');
    });

</script>



而且我没有忘记将这两个放在_Layout.vbhtml
的HEAD部分中



and I didn''t forgot to put those two in the HEAD section in _Layout.vbhtml

<link href="@Url.Content("~/jtable/themes/standard/blue/jtable_blue.css")" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="@Url.Content("~/jtable/jquery.jtable.js")"></script>



因为这只是我的第一步,所以我的表[user]仅包含两个字段{UserId,Name}

我在这里想念什么?
预先谢谢您..



as it is only my first steps my table [user] consist only two fields {UserId,Name}

What am I missing here?
thank you in advance..

推荐答案

(文档).ready(
(document).ready(function () {


(#UserTableContainer ').jtable({ 标题:' 用户列表', 分页: true , pageSize: 10 , 动作:{ listAction:' @ Url.Action("UserList")', deleteAction:' @ Url.Action("DeleteUser")', updateAction:' @ Url.Action("UpdateUser")', createAction:' @ Url.Action("CreateUser")' }, 栏位:{ 用户身份: { 键: true , 创建: false false , 列表:错误 }, 姓名: { 标题:' 名称', 宽度:' 100%' } } }); // 从服务器加载用户列表
('#UserTableContainer').jtable({ title: 'User List', paging: true, pageSize: 10, actions: { listAction: '@Url.Action("UserList")', deleteAction: '@Url.Action("DeleteUser")', updateAction: '@Url.Action("UpdateUser")', createAction: '@Url.Action("CreateUser")' }, fields: { UserId: { key: true, create: false, edit: false, list: false }, Name: { title: 'Name', width: '100%' } } }); //Load user list from server


(' #UserTableContainer').jtable(' 加载'); }); < / 脚本 >
('#UserTableContainer').jtable('load'); }); </script>



而且我没有忘记将这两个放在_Layout.vbhtml
的HEAD部分中



and I didn''t forgot to put those two in the HEAD section in _Layout.vbhtml

<link href="@Url.Content("~/jtable/themes/standard/blue/jtable_blue.css")" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="@Url.Content("~/jtable/jquery.jtable.js")"></script>



因为这只是我的第一步,所以我的表[user]仅包含两个字段{UserId,Name}

我在这里想念什么?
预先谢谢您..



as it is only my first steps my table [user] consist only two fields {UserId,Name}

What am I missing here?
thank you in advance..


这篇关于ASP.NET MVC 3&amp; jTable-初学者的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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