123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- (function () {
- var BSTreeTable = function (bstableId, url, columns) {
- this.btInstance = null;
- this.bstableId = bstableId;
- this.url = Feng.ctxPath + url;
- this.method = "post";
- this.columns = columns;
- this.data = {};
- this.expandColumn = null;
- this.id = 'id';
- this.code = 'code';
- this.parentCode = 'pcode';
- this.expandAll = false;
- this.toolbarId = bstableId + "Toolbar";
- this.height = 665;
- };
- BSTreeTable.prototype = {
-
- init: function () {
- var tableId = this.bstableId;
- this.btInstance =
- $('#'+tableId).bootstrapTreeTable({
- id: this.id,
- code: this.code,
- parentCode: this.parentCode,
- rootCodeValue: this.rootCodeValue,
- type: this.method,
- url: this.url,
- ajaxParams: this.data,
- expandColumn: this.expandColumn,
- striped: true,
- expandAll: this.expandAll,
- columns: this.columns,
- toolbar: "#" + this.toolbarId,
- height: this.height,
- });
- return this;
- },
-
- setExpandColumn: function (expandColumn) {
- this.expandColumn = expandColumn;
- },
-
- setIdField: function (id) {
- this.id = id;
- },
-
- setCodeField: function (code) {
- this.code = code;
- },
-
- setParentCodeField: function (parentCode) {
- this.parentCode = parentCode;
- },
-
- setRootCodeValue: function (rootCodeValue) {
- this.rootCodeValue = rootCodeValue;
- },
-
- setExpandAll: function (expandAll) {
- this.expandAll = expandAll;
- },
-
- setHeight: function (height) {
- this.height = height;
- },
-
- 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") ? $("#" + key).val() : value;
- }
- return this;
- },
-
- setData: function (data) {
- this.data = data;
- return this;
- },
-
- clear: function () {
- this.data = {};
- return this;
- },
-
- refresh: function (parms) {
- if (typeof parms != "undefined") {
- this.btInstance.bootstrapTreeTable('refresh', parms.query);
- } else {
- this.btInstance.bootstrapTreeTable('refresh');
- }
- }
- };
- window.BSTreeTable = BSTreeTable;
- }());
|