私はいくつかの助けを使うことができます。ajax を使用しているページに jQuery Bootgrid があります。データが適切にロードされ、グリッドが適切にレンダリングされている間。検索ボックス、並べ替え、更新など、どの機能も正しく動作していないようです。同様に、JavaScript エラーも発生しません。
以下を参考にしています
- jquery.bootgrid.min.css
- jquery.bootgrid.min.js
- jquery.bootgrid.fa.min.js
私のコードはかなり基本的です
HTML
<table id="jobGrid" class="table table-condensed table-hover table-striped">
<thead>
<tr>
<th data-column-id="JobNumber" data-identifier="true" data-type="string">Job Number</th>
<th data-column-id="JobName" data-type="string">Job Name</th>
<th data-column-id="JobState" data-type="string">Request State</th>
<th data-column-id="JobStatus" data-type="string">Status</th>
<th data-column-id="JobRequestor" data-type="string">Requestor</th>
<th data-column-id="LastModifiedDate" data-type="date" data-order="desc">Last Modified</th>
<th data-column-id="commands" data-formatter="commands" data-sortable="false">Commands</th>
</tr>
</thead>
</table>
JavaScript
// Planning Filter
var planningFilter = function () {
// NOTE: I have multiple types of basic filters.
// eg: Planning, Approved, Completed
$("#jobGrid").bootgrid("destroy");
var grid = $("#jobGrid").bootgrid({
ajax: true,
ajaxSettings: {
method: "GET",
cache: false
},
url: RestService.GetJobsInPlanningSvr(),
formatters: {
"commands": function (column, row) {
return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\" data-row-id=\"" + row.JobNumber + "\"><span class=\"fa fa-pencil\"></span> View Details</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"));
});
});
}
JSON 結果
{
"current":1,
"rowCount":10,
"rows":[
{"CustomerID":"88888888-8888-8888-8888-888888888888","JobNumber":"DMPC-2","JobName":"DMPC-2: Transfer 645 Units to Warehouse","JobState":"Request Draft","JobStatus":"In Planning","JobRequestor":"Jim Halpert","LastModifiedUTS":1439768413,"LastModifiedDate":"8/16/2015"},
{"CustomerID":"88888888-8888-8888-8888-888888888888","JobNumber":"DMPC-1","JobName":"DMPC-1: Scranton Chamber of Commerce Delivery","JobState":"Request Draft","JobStatus":"Pending Approval","JobRequestor":"Dwight Schrute","LastModifiedUTS":1440009361,"LastModifiedDate":"8/19/2015"}
],
"total":2
}
そして、それは基本的にそれです...あなたが見ることができるどの機能も機能しない理由は...注:ページネーションをテストしていませんが、これが機能しなくても驚かないでしょう.
ご協力いただきありがとうございます