bootstrap 的paginator组件怎么用啊,我前台jquery代码如下,控制器里怎么接受page啊

qq_41008959 qq_41008959 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
$(function ()
{
var options = {
currentPage: 1,
totalPages: $('#totalpage').val(),
numberofpages: 2,
itemTexts: function (type, page, current) {
switch (type) {
case "first":
return "首页";
case "prev":
return "上一页";
case "next":
return "下一页";
case "last":
return "末页";
case "page":
return page;


}
}, onPageClicked: function (event,originalEvent,type,page) {

var json = { page: page };
var jsonStr=JSON.stringify(json);
$.ajax({
url: "Book/List",
type:"post",
data:jsonStr,
success: function (data)
{
$('#logtable').html(data);
}
});
},

};
$('#example').bootstrapPaginator(options);
});

HTML
<div id="logtable">
<table id="table" class="table">
<thead>
<tr>
<th>操作</th>
<th>ID</th>
<th>BookName</th>
<th>BookType</th>
<th>Author </th>
<th>PubData</th>
<th>PubTime</th>
<th>删除</th>
<th>编辑</th>
<th>添加</th>
</tr>
</thead>
<tbody>
@if (Model.Count!=0)
{
foreach (var item in Model)
{
<tr>
<th>@Html.CheckBox("chk",false)</th>
<th>@item.ID</th>
<th>@item.BookName</th>
<th>@item.BookType.BookTypeName</th>
<th>@item.Author</th>
<th>@item.PubData</th>
<th>@item.PubTime</th>
<th>@Html.ActionLink("删除", "DeleteById", new{ id=item.ID }, new { onclick="return confirm('确认删除吗')" })</th>
<th>@Html.ActionLink("编辑", "UpdateBookById", new { id = item.ID }, new { onclick="return confirm('确认编辑吗')" })</th>
<th>@Html.ActionLink("添加", "Add", new { onclick="return confirm('确认添加吗')" })</th>
</tr>
}
}

</tbody>


</table>

请输入课程名字关键字: <input id="val" type="text" /><input type="button" value="查询" id="btn_Find" />
<input id="btn" type="button" value="批量删除" />
</div>


<div id="example"></div>

<input type="hidden" id="totalpage" value="@ViewBag.TotalPage" />



控制器
public ActionResult List(int? page,int take=2)
{

using (EFDbCotext dbcontext=new EFDbCotext())
{
if (page.HasValue)
{
var sr = new StreamReader(Request.InputStream);
var str = sr.ReadToEnd();

page = Convert.ToInt32(sr.ReadToEnd());
}
else
{
page = 1;
}


var model = BookService.GetAllBook();


int count = PageDive.GetAllBookCount();
int totalPage = count / take;

ViewBag.TotalPage = totalPage;

var data = model.Skip(take * ((int)page - 1)).Take(take).ToList();

return View(data);


}


}

不会写控制器,乱写的。请大家看看应该怎么写。我的写法分页点击页码没用。
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
qq_41008959
.NET社区 62,275 成员 668,968 内容