I am using Jquery-Bootgrid. http://www.jquery-bootgrid.com/
I need a situation where user can select a Row, then the user clicks a button for Edit/Delete.
I want this to be re-useable. So I have created a Method:
function dataTable() {
var self = this;
self.tableListUrl = "";
self.gridObject = null;
self.InitilizeAjaxTable = function (tableDiv, tableListUrl) {
parameters = parameters || "";
self.tableListUrl = tableListUrl;
self.gridObject = $("#" + tableDiv).bootgrid({
formatters: {
"actions": function (column, row) {
return "";
}
},
rowCount: [5, 10, 25, 50, -1],
requestHandler: function (request) {
var model = fleetMaintenance.filterModel.GetModel();
model.Current = request.current;
model.RowCount = request.rowCount;
model.Search = request.searchPhrase;
return JSON.stringify(model);
},
ajaxSettings: {
method: "POST",
contentType: "application/json"
},
ajax: true,
url: self.tableListUrl,
}).on("loaded.rs.jquery.bootgrid", function (e) {
alert('Loaded');
});
}).on("click.rs.jquery.bootgrid", function (e, columns, row) {
});
},
self.RefreshTable = function () {
self.gridObject.bootgrid("reload");
},
}
Then I can initialize my table using:
<script type="text/javascript">
$(function() {
var dt = new dataTable();
dt.InitilizeAjaxTable("sitesList", '@Url.Action("SitesList","Sites")');
});
</script>
HTML:
<table id="sitesList" class="table table-hover table-striped">
<thead>
<tr>
<th data-column-id="iSiteId" data-visible="false" data-identifier="true" data-type="numeric" data-sortable="false">Site Id</th>
<th data-column-id="sSiteName" data-order="desc">Site Name</th>
<th data-column-id="sNotes">Notes</th>
<th data-column-id="sAddress">Address</th>
<th data-column-id="sCity">City</th>
</tr>
</thead>
<tbody></tbody>
</table>
I know I can set the rowSelect
and the selection
to true
.
I can bind the click event on the button, what I need to know is How can I append a button at the start of this table with data attributes?