jQuery技术

jQuery Bootgrid(2)

字号+ 作者:H5之家 来源:H5之家 2017-09-19 14:28 我要评论( )

HTMLtable data-toggle="bootgrid" data-ajax="true" data-url="/api/data/basic"theadtrth data-column-id="id" data-type="numeric" data-identifier="true"ID/thth data-column-id="sender"Sender/thth data-col

HTML <table data-toggle="bootgrid" data-ajax="true" data-url="/api/data/basic"> <thead> <tr> <th data-column-id="id" data-type="numeric" data-identifier="true">ID</th> <th data-column-id="sender">Sender</th> <th data-column-id="received" data-order="desc">Received</th> </tr> </thead> </table> POST Body (Request) current=1&rowCount=10&sort[sender]=asc&searchPhrase= JSON (Response) { "current": 1, "rowCount": 10, "rows": [ { "id": 19, "sender": "123@test.de", "received": "2014-05-30T22:15:00" }, { "id": 14, "sender": "123@test.de", "received": "2014-05-30T20:15:00" }, ... ], "total": 1123 }

Command Buttons Example

Start Example

ID Sender Received Commands

Code

HTML <table> <thead> <tr> <th data-column-id="id" data-type="numeric">ID</th> <th data-column-id="sender">Sender</th> <th data-column-id="received" data-order="desc">Received</th> <th data-column-id="commands" data-formatter="commands" data-sortable="false">Commands</th> </tr> </thead> </table> JavaScript var grid = $("#grid-command-buttons").bootgrid({ ajax: true, post: function () { return { id: "b0df282a-0d67-40e5-8558-c9e93b7befed" }; }, url: "/api/data/basic", formatters: { "commands": function(column, row) { return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\" data-row-id=\"" + row.id + "\"><span class=\"fa fa-pencil\"></span></button> " + "<button type=\"button\" class=\"btn btn-xs btn-default command-delete\" data-row-id=\"" + row.id + "\"><span class=\"fa fa-trash-o\"></span></button>"; } } }).on("loaded.rs.jquery.bootgrid", function() { /* Executes after data is loaded and rendered */ grid.find(".command-edit").on("click", function(e) { alert("You pressed edit on row: " + $(this).data("row-id")); }).end().find(".command-delete").on("click", function(e) { alert("You pressed delete on row: " + $(this).data("row-id")); }); }); POST Body (Request) current=1&rowCount=10&sort[sender]=asc&searchPhrase=&id=b0df282a-0d67-40e5-8558-c9e93b7befed JSON (Response) { "current": 1, "rowCount": 10, "rows": [ { "id": 19, "sender": "123@test.de", "received": "2014-05-30T22:15:00" }, { "id": 14, "sender": "123@test.de", "received": "2014-05-30T20:15:00" }, ... ], "total": 1123 }

More Examples

More examples like manipulation will follow very soon. For experienced developer I recommend to see in code how feature-rich and flexible jQuery Bootgrid is. Here you see only a small set of features.

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • 如何学习jquery, 学习方法、书籍全攻略

    如何学习jquery, 学习方法、书籍全攻略

    2017-09-20 09:05

  • 测试 jQuery

    测试 jQuery

    2017-09-19 09:04

  • jQuery 效果:clearQueue() 方法停止队列中所有仍未执行的函数

    jQuery 效果:clearQueue() 方法停止队列中所有仍未执行的函数

    2017-09-19 08:00

  • jquery.cookie的使用

    jquery.cookie的使用

    2017-09-18 13:04

网友点评