problem description
detailView detailFormatter is not available when using BootStrap Table to encapsulate js
the environmental background of the problems and what methods you have tried
it"s OK to use the default method:
$("- sharptableCompany"). BootstrapTable ({
height: 650,
detailView: true,
detailFormatter: function (index, row) {
return "<div class="form-group has-success"><label class="col-sm-2 control-label">:</label><label class="col-sm-4">" + row.Remark + "</label><label class="col-sm-2 control-label">:</label><label class="col-sm-4">" + timeFormatter(row.LogTime) + "</label></div></br>";
},
columns: [
],
});
there is a problem with the encapsulated js as follows:
var tableList = { id:"listTable"};
$(function () {
var defaultColunms = tableList.initColumn();
var config = {
detailView: true,
detailFormatter: function (index, row) {
return "<div class="form-group has-success"><label class="col-sm-2 control-label">:</label><label class="col-sm-4">" + row.Remark + "</label><label class="col-sm-2 control-label">:</label><label class="col-sm-4">" + timeFormatter(row.LogTime) + "</label></div></br>";
}}
var table = new BSTable(tableList.id, "/Company/GetJsonData", defaultColunms,config );
tableList.table = table.init();
});
tableList.initColumn = function () {
return []}
related codes
/ / Please paste the code text below (do not replace the code with pictures)
Encapsulation js:
(function () {
var BSTable = function (bstableId, url, columns, extendConfig) {
this.btInstance = null;//jqueryBootStrapTable
this.bstableId = bstableId;
this.url = url;
this.method = "get";
this.paginationType = "server";//,"client"
this.toolbarId = bstableId + "Toolbar";
this.columns = columns;
this.height = 690;//690
this.data = {};
this.queryParams = {}; //
this.extendConfig = extendConfig;
};
BSTable.prototype = {
/**
* bootstrap table
*/
init: function () {
var tableId = this.bstableId;
var qParams = this.queryParams;
var defaultConfig = {
contentType: "application/json",
url: this.url, //
method: this.method, //ajax,postget
ajaxOptions: { //ajax
data: this.data
},
toolbar: "-sharp" + this.toolbarId,//
striped: true, //
cache: false, //,true
pagination: true, //*
sortable: true, //
sortOrder: "asc", //
pageNumber: 1, //
pageSize: 15, //*
pageList: [15, 30, 50, 100], //*
queryParamsType: "limit", // "limit" , :offset,limit,sort
queryParams: function (params) {
var temp = {
rows: params.limit,
page: (params.offset) / params.limit + 1,
sidx: params.sort,
sord: params.order,
keywords: params.search
};
return $.extend(temp, qParams);
}, //
sidePagination: this.paginationType, //:clientserver*
search: true, //
strictSearch: false, // true
showColumns: true, //
showRefresh: true, //
minimumCountColumns: 2, //
clickToSelect: true, //
searchOnEnterKey: false, // true
columns: this.columns, //
height: this.height,
icons: {
refresh: "glyphicon-repeat",
toggle: "glyphicon-list-alt",
columns: "glyphicon-list"
},
iconSize: "outline"
};
var bsTableConfig = {};
if (typeof this.extendConfig == "object") {
bsTableConfig = $.extend(defaultConfig, this.extendConfig);
}
else {
bsTableConfig = defaultConfig;
}
console.log(bsTableConfig);
this.btInstance =
$("-sharp" + tableId).bootstrapTable(bsTableConfig);
return this;
},
/**
*
* refreshurl
* @param param
*/
setQueryParams: function (param) {
this.queryParams = param;
},
/**
* :server client
*/
setPaginationType: function (type) {
this.paginationType = type;
},
/**
* ajax post
*/
set: function (key, value) {
if (typeof key == "object") {
for (var i in key) {
if (typeof i == "function")
continue;
this.data[i] = key[i];
}
} else {
this.data[key] = (typeof value == "undefined") ? $("-sharp" + key).val() : value;
}
return this;
},
/**
* ajax post
*/
setData: function (data) {
this.data = data;
return this;
},
/**
* ajax post
*/
clear: function () {
this.data = {};
return this;
},
/**
* bootstrap
* Refresh the remote server data,
* you can set {silent: true} to refresh the data silently,
* and set {url: newUrl} to change the url.
* To supply query params specific to this request, set {query: {foo: "bar"}}
*/
refresh: function (parms) {
if (typeof parms != "undefined") {
this.btInstance.bootstrapTable("refresh", parms);
} else {
this.btInstance.bootstrapTable("refresh");
}
},
/**
*
*/
getSelections: function () {
return this.btInstance.bootstrapTable("getSelections");
}
};
window.BSTable = BSTable;
} ());
what result do you expect? What is the error message actually seen?
expected result:
js: