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
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
Dim UserCount = db.User.Count
Dim Users As New List(Of User)(db.User.Skip(jtStartIndex).Take(jtPageSize))
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
@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%'
}
}
});
$('#UserTableContainer').jtable('load');
});
</script>
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>
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..