日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql使用jtable_jtable 的简单使用

發布時間:2023/12/10 数据库 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql使用jtable_jtable 的简单使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

做后臺管理管理系統時,基于ajax的數據操作和富有表現力的數據綁定插件jtable絕對是一個不錯的選擇,他接收來自服務器端的json格式的數據。而且他是一款開源的基于jquery和jquery ui的插件,您可以根據自己的需要修改其表現,如css,甚至修改其源碼,讓其符合您的需求。

下面我將介紹在asp.net mvc3.0 和ssh框架下jtable的使用

2 將相應的css (jtable.css)和jquery.jtable.zh-CN.js、jquery.jtable.min.js拷到您的項目下。

3?引入插件,在view中,一般放在模板頁中,為了簡單,我放在AdministratorController下的Index Action對應的視圖中,即Index.aspx頁面中

4 編寫javascript代碼綁定數據

$("#smallTypeList").jtable({

title:"商品小類別管理列表",

paging:true,

pageSize:10,

selecting:true, //Enable selecting

multiselect: true, //Allow multiple selecting

selectingCheckboxes: true,

actions: {

listAction:"/Administrator/GoodsSmallTypeList",

createAction:"/Administrator/GoodsSmallTypeCreate",

updateAction:'/Administrator/GoodsSmallTypeUpdate',

deleteAction:'/Administrator/GoodsSmallTypeDelete'},

fields: {

sid: {

key:true,

list:false,

create:false,

edit:false},

sname: {

title:"名稱",

width:"30%",

inputClass:"validate[required]"},

cid: {

title:"類別",

width:"30%",

options:"/Administrator/CateList"},

spic: {

title:"類別圖片",

width:"30%",

options: {'暫無':'暫無'}

}});

$("#smallTypeList").jtable("load");

});

5 在controller中輸出json

為了簡單,省略Models層的代碼,筆者認為您已經具備一定的asp.net mvc的基礎知識。

綁定數據,注意參數(jtableStartIndex,jtPageSize)

第一個參數用來指定當前起始記錄,第二個用來指定一頁顯示的記錄行,用這兩個參數實現分頁。

public JsonResult GoodsSmallTypeList(int jtStartIndex, intjtPageSize)

{try{int totalCount =goodscateEntity.getAllCategorys().Count();var goodsSmallList =goodscateEntity.getAllCategorys().Skip(jtStartIndex).Take(jtPageSize);return Json(new { Result = "OK", Records = goodsSmallList, TotalRecordCount =totalCount });

}catch(Exception ex)

{return Json(new { Result = "ERROR", Message =ex.Message.ToString() });

}

}

代碼中,返回json時參數的OK表示請求狀態,Records表示數據集合,TotalRecordCount表示總記錄數。一般這些參數的約定好的,不可改成其他,除非你不愿意使用。您可以在jtable源碼中進行修改。

publicJsonResult GoodsSmallTypeCreate(tb_goodsCategory category)

{try{if (!ModelState.IsValid)

{return Json(new { Result = "ERROR", Message = "請填寫信息完整"});

}bool l =goodscateEntity.InsertGoodsCategory(category);return Json(new { Result = "OK", Record =category });

}catch(Exception ex)

{return Json(new { Result = "ERROR", Message =ex.Message.ToString() });

}

}///

///修改商品類型///

///

///

publicJsonResult GoodsSmallTypeUpdate(tb_goodsCategory category)

{try{bool l =goodscateEntity.ModifyGoodsCateGory(category);return Json(new { Result = "OK", Record =category });

}catch(Exception ex)

{return Json(new { Result = "ERROR", Message =ex.Message.ToString() });

}

}///

///刪除商品類型///

///

///

public JsonResult GoodsSmallTypeDelete(int?sid)

{try{bool l =goodscateEntity.DeleteGoodsCategory(sid);return Json(new { Result = "OK"});

}catch(Exception ex)

{return Json(new { Result = "ERROR", Message =ex.Message.ToString() });

}

}

運行結果:

這樣,jtable的使用描述就此完成,本人技術有限,文中還有許多不足,希望大家批評指正,謝謝。

使用 SSH很簡單,只要的struts.xml加入相關配置,使其返回的數據為json即可。?當然要引入json對應的jar包哦。希望對大家有用。

總結

以上是生活随笔為你收集整理的mysql使用jtable_jtable 的简单使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。