2024-10-10
This commit is contained in:
72
web/bsadmin/assets/js/lib/jsgrid/jsgrid.field.js
Normal file
72
web/bsadmin/assets/js/lib/jsgrid/jsgrid.field.js
Normal file
@@ -0,0 +1,72 @@
|
||||
(function(jsGrid, $, undefined) {
|
||||
|
||||
function Field(config) {
|
||||
$.extend(true, this, config);
|
||||
this.sortingFunc = this._getSortingFunc();
|
||||
}
|
||||
|
||||
Field.prototype = {
|
||||
name: "",
|
||||
title: null,
|
||||
css: "",
|
||||
align: "",
|
||||
width: 100,
|
||||
|
||||
visible: true,
|
||||
filtering: true,
|
||||
inserting: true,
|
||||
editing: true,
|
||||
sorting: true,
|
||||
sorter: "string", // name of SortStrategy or function to compare elements
|
||||
|
||||
headerTemplate: function() {
|
||||
return (this.title === undefined || this.title === null) ? this.name : this.title;
|
||||
},
|
||||
|
||||
itemTemplate: function(value, item) {
|
||||
return value;
|
||||
},
|
||||
|
||||
filterTemplate: function() {
|
||||
return "";
|
||||
},
|
||||
|
||||
insertTemplate: function() {
|
||||
return "";
|
||||
},
|
||||
|
||||
editTemplate: function(value, item) {
|
||||
this._value = value;
|
||||
return this.itemTemplate(value, item);
|
||||
},
|
||||
|
||||
filterValue: function() {
|
||||
return "";
|
||||
},
|
||||
|
||||
insertValue: function() {
|
||||
return "";
|
||||
},
|
||||
|
||||
editValue: function() {
|
||||
return this._value;
|
||||
},
|
||||
|
||||
_getSortingFunc: function() {
|
||||
var sorter = this.sorter;
|
||||
|
||||
if($.isFunction(sorter)) {
|
||||
return sorter;
|
||||
}
|
||||
|
||||
if(typeof sorter === "string") {
|
||||
return jsGrid.sortStrategies[sorter];
|
||||
}
|
||||
|
||||
throw Error("wrong sorter for the field \"" + this.name + "\"!");
|
||||
}
|
||||
};
|
||||
|
||||
jsGrid.Field = Field;
|
||||
|
||||
}(jsGrid, jQuery));
|
||||
Reference in New Issue
Block a user