国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > JS > 正文

BootStrap table實(shí)現(xiàn)表格行拖拽效果

2024-05-06 16:46:59
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

本文實(shí)例為大家分享了BootStrap table實(shí)現(xiàn)表格行拖拽的具體代碼,供大家參考,具體內(nèi)容如下

不上圖了

首先還是得添加三個(gè)文件,自己上網(wǎng)搜搜就行

<script src="~/Content/bootstrap-table/jquery.tablednd.js"></script><script src="~/Content/bootstrap-table/bootstrap-table-reorder-rows.js"></script><link href="~/Content/bootstrap-table/bootstrap-table-reorder-rows.css" rel="external nofollow" rel="stylesheet"/>

前臺(tái),加在Bootstrap Table 屬性里面  

//當(dāng)選中行,拖拽時(shí)的哪行數(shù)據(jù),并且可以獲取這行數(shù)據(jù)的上一行數(shù)據(jù)和下一行數(shù)據(jù)      onReorderRowsDrag: function(table, row) {        //取索引號(hào)        dragbeforeidx = $(row).attr("data-index");      },      //拖拽完成后的這條數(shù)據(jù),并且可以獲取這行數(shù)據(jù)的上一行數(shù)據(jù)和下一行數(shù)據(jù)      onReorderRowsDrop: function (table, row) {        //取索引號(hào)        draglateridx = $(row).attr("data-index");      },      //當(dāng)拖拽結(jié)束后,整個(gè)表格的數(shù)據(jù)      onReorderRow: function (newData) {        //這里的newData是整個(gè)表格數(shù)據(jù),數(shù)組形式        if (dragbeforeidx != draglateridx) {//這是我其他地方需要的,你們可不必要這個(gè)          //console.log(newData); 調(diào)試用代碼          $.post("Sort",            { jsondata: JSON.stringify(newData) },//將整張表數(shù)據(jù)Post,當(dāng)然,先序列化成Json            function(data) {              if (data == "success") {                $table.bootstrapTable('refresh');              }            });        }      }

后臺(tái)代碼Controller

public string Sort(string jsondata)    {      //將json序列化為L(zhǎng)ist<T>      JavaScriptSerializer serializer = new JavaScriptSerializer();      List<WorkFlow> list = serializer.Deserialize<List<WorkFlow>>(jsondata);      BLL.Base.WorkFlow bllworkflow = new BLL.Base.WorkFlow();      var result = bllworkflow.Sort(list);      return result;    }

排序的思路:當(dāng)前臺(tái)拖動(dòng)完成后,將整個(gè)表格數(shù)據(jù)傳入后臺(tái),先刪除之前數(shù)據(jù)庫(kù)中的數(shù)據(jù),重新保存當(dāng)前數(shù)據(jù)實(shí)現(xiàn)排序。

缺點(diǎn):  如果你有分頁(yè)顯示,返回的Table數(shù)據(jù)只為第一頁(yè)的。第二頁(yè)就會(huì)出現(xiàn)排序問(wèn)題。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持VeVb武林網(wǎng)。


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到JavaScript/Ajax教程頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 鸡泽县| 西贡区| 宁远县| 衡山县| 衡南县| 鄂伦春自治旗| 镇康县| 濮阳县| 习水县| 阆中市| 晋中市| 鄂温| 景德镇市| 仪征市| 敦化市| 阿巴嘎旗| 济阳县| 龙海市| 农安县| 邮箱| 班玛县| 潮州市| 湖南省| 丁青县| 宜春市| 灌南县| 金寨县| 利辛县| 潞城市| 长子县| 南皮县| 绥中县| 松溪县| 台南县| 永兴县| 贞丰县| 遂平县| 赤壁市| 普洱| 乡宁县| 沙坪坝区|