jQuery Bootgrid Not Working Properly -
i use help. have jquery bootgrid on page using ajax. while data loads , grid rendered. none of features seem work including search box, sorting, refresh, etc. likewise getting no javascript errors.
i referencing following
- jquery.bootgrid.min.css
- jquery.bootgrid.min.js
- jquery.bootgrid.fa.min.js
my code pretty basic
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: 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 loaded , rendered */ grid.find(".command-edit").on("click", function (e) { alert("you pressed edit on row: " + $(this).data("row-id")); }); }); }
json result
{ "current":1, "rowcount":10, "rows":[ {"customerid":"88888888-8888-8888-8888-888888888888","jobnumber":"dmpc-2","jobname":"dmpc-2: transfer 645 units 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 }
and that's it... reason why none of features not working can see... not: have not tested pagination not surprise me if did not work either.
thanks help
the problem is, function executed before page elements loaded.
you can put function inside $(function() { });
e.g
$(function() { // planning filter var planningfilter = function () { // note: 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: "data.json", 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 loaded , rendered */ grid.find(".command-edit").on("click", function (e) { alert("you pressed edit on row: " + $(this).data("row-id")); }); }); } planningfilter(); });
Comments
Post a Comment