我將使用使用模板填充的kendo網格實現拖放行爲。我如何實現可拖動的行並使用劍道網格重新排序。Kendo Grid Kendo模板的可拖拽行
0
A
回答
0
.Orderable()
作品一種享受。也許嘗試「.Dragable()」雖然我有點不確定。
0
看看下面我的演示代碼,並嘗試實施。
var data = [
{ id: 1, text: "text 1", position: 0 },
{ id: 2, text: "text 2", position: 1 },
{ id: 3, text: "text 3", position: 2 }
]
var dataSource = new kendo.data.DataSource({
data: data,
schema: {
model: {
id: "id",
fields: {
id: { type: "number" },
text: { type: "string" },
position: { type: "number" }
}
}
}
});
var grid = $("#grid").kendoGrid({
dataSource: dataSource,
scrollable: false,
columns: ["id", "text", "position"]
}).data("kendoGrid");
grid.table.kendoDraggable({
filter: "tbody > tr",
group: "gridGroup",
hint: function(e) {
return $('<div class="k-grid k-widget"><table><tbody><tr>' + e.html() + '</tr></tbody></table></div>');
}
});
grid.table/*.find("tbody > tr")*/.kendoDropTarget({
group: "gridGroup",
drop: function(e) {
var target = dataSource.get($(e.draggable.currentTarget).data("id")),
dest = $(e.target);
if (dest.is("th")) {
return;
}
dest = dataSource.get(dest.parent().data("id"));
//not on same item
if (target.get("id") !== dest.get("id")) {
//reorder the items
var tmp = target.get("position");
target.set("position", dest.get("position"));
dest.set("position", tmp);
dataSource.sort({ field: "position", dir: "asc" });
}
}
});
0
把.Dragable() 但要確保你坐在它在正確的地方,需要訂貨。有時候你可能沒有得到預期的結果,這可能是因爲沒有注意到訂單。
相關問題
- 1. Kendo UI Grid Grid模板
- 2. Kendo UI Grid Grid模板
- 3. Kendo Grid外鍵模板
- 4. 模板無效 - Kendo Grid
- 5. Kendo Grid模板與JQuery的迷你圖
- 6. Kendo UI MVC Grid - DataSource干擾列模板
- 7. Kendo UI Web Grid - Popup_Editor模板 - Dropdown
- 8. 使用Angular模板進行Kendo UI Grid詳細模板
- 9. Kendo TabStrip和Kendo模板
- 10. Kendo Listview + Kendo DataSource +模板
- 11. Kendo dropdown - 模板
- 12. Kendo UI Grid多選拖放問題
- 13. Kendo UI Grid:添加包含影響模板的變量的行
- 14. 如何在使用Kendo Grid時爲單行設置行模板?
- 15. Kendo Grid FilterMenu
- 16. Kendo Grid with DropdownList
- 17. Kendo UI Grid,Durandal
- 18. Kendo Grid plumbing
- 19. kendo grid multi filterable
- 20. Kendo Grid Computed Column
- 21. kendo grid cancelChanges issue
- 22. Kendo UI模板中的Javascript
- 23. Kendo內部的Kendo MVC Grid TabStrip
- 24. Kendo Grid:禁用行編輯
- 25. Kendo UI Grid獲取行值
- 26. Kendo Grid - 行展開動畫
- 27. Kendo UI Grid - 顯示行號
- 28. Kendo Grid - 多個頁腳行
- 29. Kendo Grid內部的Kendo日期選擇器Tabstrip - 無效的模板
- 30. Kendo Grid模板 - 在模板中使用Javascript變量
你好那裏.... –