|
@@ -1,7 +1,7 @@
|
|
|
/*!
|
|
/*!
|
|
|
* ZUI: 数据表格② - v1.8.1 - 2018-01-18
|
|
* ZUI: 数据表格② - v1.8.1 - 2018-01-18
|
|
|
* http://zui.sexy
|
|
* http://zui.sexy
|
|
|
- * GitHub: https://github.com/easysoft/zui.git
|
|
|
|
|
|
|
+ * GitHub: https://github.com/easysoft/zui.git
|
|
|
* Copyright (c) 2018 cnezsoft.com; Licensed MIT
|
|
* Copyright (c) 2018 cnezsoft.com; Licensed MIT
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
@@ -13,8 +13,8 @@
|
|
|
* http://jquery.org/license
|
|
* http://jquery.org/license
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-(function (factory) {
|
|
|
|
|
- if ( typeof define === 'function' && define.amd ) {
|
|
|
|
|
|
|
+(function(factory) {
|
|
|
|
|
+ if (typeof define === 'function' && define.amd) {
|
|
|
// AMD. Register as an anonymous module.
|
|
// AMD. Register as an anonymous module.
|
|
|
define(['jquery'], factory);
|
|
define(['jquery'], factory);
|
|
|
} else if (typeof exports === 'object') {
|
|
} else if (typeof exports === 'object') {
|
|
@@ -24,17 +24,16 @@
|
|
|
// Browser globals
|
|
// Browser globals
|
|
|
factory(jQuery);
|
|
factory(jQuery);
|
|
|
}
|
|
}
|
|
|
-}(function ($) {
|
|
|
|
|
|
|
+}(function($) {
|
|
|
|
|
|
|
|
- var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
|
|
|
|
|
- toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
|
|
|
|
|
- ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
|
|
|
|
|
- slice = Array.prototype.slice,
|
|
|
|
|
|
|
+ var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
|
|
|
|
|
+ toBind = ('onwheel' in document || document.documentMode >= 9) ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
|
|
|
|
|
+ slice = Array.prototype.slice,
|
|
|
nullLowestDeltaTimeout, lowestDelta;
|
|
nullLowestDeltaTimeout, lowestDelta;
|
|
|
|
|
|
|
|
- if ( $.event.fixHooks ) {
|
|
|
|
|
- for ( var i = toFix.length; i; ) {
|
|
|
|
|
- $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
|
|
|
|
|
|
|
+ if ($.event.fixHooks) {
|
|
|
|
|
+ for (var i = toFix.length; i;) {
|
|
|
|
|
+ $.event.fixHooks[toFix[--i]] = $.event.mouseHooks;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -42,9 +41,9 @@
|
|
|
version: '3.1.12',
|
|
version: '3.1.12',
|
|
|
|
|
|
|
|
setup: function() {
|
|
setup: function() {
|
|
|
- if ( this.addEventListener ) {
|
|
|
|
|
- for ( var i = toBind.length; i; ) {
|
|
|
|
|
- this.addEventListener( toBind[--i], handler, false );
|
|
|
|
|
|
|
+ if (this.addEventListener) {
|
|
|
|
|
+ for (var i = toBind.length; i;) {
|
|
|
|
|
+ this.addEventListener(toBind[--i], handler, false);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
this.onmousewheel = handler;
|
|
this.onmousewheel = handler;
|
|
@@ -55,9 +54,9 @@
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
teardown: function() {
|
|
teardown: function() {
|
|
|
- if ( this.removeEventListener ) {
|
|
|
|
|
- for ( var i = toBind.length; i; ) {
|
|
|
|
|
- this.removeEventListener( toBind[--i], handler, false );
|
|
|
|
|
|
|
+ if (this.removeEventListener) {
|
|
|
|
|
+ for (var i = toBind.length; i;) {
|
|
|
|
|
+ this.removeEventListener(toBind[--i], handler, false);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
this.onmousewheel = null;
|
|
this.onmousewheel = null;
|
|
@@ -82,7 +81,7 @@
|
|
|
|
|
|
|
|
settings: {
|
|
settings: {
|
|
|
adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
|
|
adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
|
|
|
- normalizeOffset: true // calls getBoundingClientRect for each event
|
|
|
|
|
|
|
+ normalizeOffset: true // calls getBoundingClientRect for each event
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -98,25 +97,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
function handler(event) {
|
|
function handler(event) {
|
|
|
- var orgEvent = event || window.event,
|
|
|
|
|
- args = slice.call(arguments, 1),
|
|
|
|
|
- delta = 0,
|
|
|
|
|
- deltaX = 0,
|
|
|
|
|
- deltaY = 0,
|
|
|
|
|
- absDelta = 0,
|
|
|
|
|
- offsetX = 0,
|
|
|
|
|
- offsetY = 0;
|
|
|
|
|
|
|
+ var orgEvent = event || window.event,
|
|
|
|
|
+ args = slice.call(arguments, 1),
|
|
|
|
|
+ delta = 0,
|
|
|
|
|
+ deltaX = 0,
|
|
|
|
|
+ deltaY = 0,
|
|
|
|
|
+ absDelta = 0,
|
|
|
|
|
+ offsetX = 0,
|
|
|
|
|
+ offsetY = 0;
|
|
|
event = $.event.fix(orgEvent);
|
|
event = $.event.fix(orgEvent);
|
|
|
event.type = 'mousewheel';
|
|
event.type = 'mousewheel';
|
|
|
|
|
|
|
|
// Old school scrollwheel delta
|
|
// Old school scrollwheel delta
|
|
|
- if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; }
|
|
|
|
|
- if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; }
|
|
|
|
|
- if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; }
|
|
|
|
|
- if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
|
|
|
|
|
|
|
+ if ('detail' in orgEvent) { deltaY = orgEvent.detail * -1; }
|
|
|
|
|
+ if ('wheelDelta' in orgEvent) { deltaY = orgEvent.wheelDelta; }
|
|
|
|
|
+ if ('wheelDeltaY' in orgEvent) { deltaY = orgEvent.wheelDeltaY; }
|
|
|
|
|
+ if ('wheelDeltaX' in orgEvent) { deltaX = orgEvent.wheelDeltaX * -1; }
|
|
|
|
|
|
|
|
// Firefox < 17 horizontal scrolling related to DOMMouseScroll event
|
|
// Firefox < 17 horizontal scrolling related to DOMMouseScroll event
|
|
|
- if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
|
|
|
|
|
|
|
+ if ('axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS) {
|
|
|
deltaX = deltaY * -1;
|
|
deltaX = deltaY * -1;
|
|
|
deltaY = 0;
|
|
deltaY = 0;
|
|
|
}
|
|
}
|
|
@@ -125,62 +124,62 @@
|
|
|
delta = deltaY === 0 ? deltaX : deltaY;
|
|
delta = deltaY === 0 ? deltaX : deltaY;
|
|
|
|
|
|
|
|
// New school wheel delta (wheel event)
|
|
// New school wheel delta (wheel event)
|
|
|
- if ( 'deltaY' in orgEvent ) {
|
|
|
|
|
|
|
+ if ('deltaY' in orgEvent) {
|
|
|
deltaY = orgEvent.deltaY * -1;
|
|
deltaY = orgEvent.deltaY * -1;
|
|
|
- delta = deltaY;
|
|
|
|
|
|
|
+ delta = deltaY;
|
|
|
}
|
|
}
|
|
|
- if ( 'deltaX' in orgEvent ) {
|
|
|
|
|
|
|
+ if ('deltaX' in orgEvent) {
|
|
|
deltaX = orgEvent.deltaX;
|
|
deltaX = orgEvent.deltaX;
|
|
|
- if ( deltaY === 0 ) { delta = deltaX * -1; }
|
|
|
|
|
|
|
+ if (deltaY === 0) { delta = deltaX * -1; }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// No change actually happened, no reason to go any further
|
|
// No change actually happened, no reason to go any further
|
|
|
- if ( deltaY === 0 && deltaX === 0 ) { return; }
|
|
|
|
|
|
|
+ if (deltaY === 0 && deltaX === 0) { return; }
|
|
|
|
|
|
|
|
// Need to convert lines and pages to pixels if we aren't already in pixels
|
|
// Need to convert lines and pages to pixels if we aren't already in pixels
|
|
|
// There are three delta modes:
|
|
// There are three delta modes:
|
|
|
// * deltaMode 0 is by pixels, nothing to do
|
|
// * deltaMode 0 is by pixels, nothing to do
|
|
|
// * deltaMode 1 is by lines
|
|
// * deltaMode 1 is by lines
|
|
|
// * deltaMode 2 is by pages
|
|
// * deltaMode 2 is by pages
|
|
|
- if ( orgEvent.deltaMode === 1 ) {
|
|
|
|
|
|
|
+ if (orgEvent.deltaMode === 1) {
|
|
|
var lineHeight = $.data(this, 'mousewheel-line-height');
|
|
var lineHeight = $.data(this, 'mousewheel-line-height');
|
|
|
- delta *= lineHeight;
|
|
|
|
|
|
|
+ delta *= lineHeight;
|
|
|
deltaY *= lineHeight;
|
|
deltaY *= lineHeight;
|
|
|
deltaX *= lineHeight;
|
|
deltaX *= lineHeight;
|
|
|
- } else if ( orgEvent.deltaMode === 2 ) {
|
|
|
|
|
|
|
+ } else if (orgEvent.deltaMode === 2) {
|
|
|
var pageHeight = $.data(this, 'mousewheel-page-height');
|
|
var pageHeight = $.data(this, 'mousewheel-page-height');
|
|
|
- delta *= pageHeight;
|
|
|
|
|
|
|
+ delta *= pageHeight;
|
|
|
deltaY *= pageHeight;
|
|
deltaY *= pageHeight;
|
|
|
deltaX *= pageHeight;
|
|
deltaX *= pageHeight;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Store lowest absolute delta to normalize the delta values
|
|
// Store lowest absolute delta to normalize the delta values
|
|
|
- absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
|
|
|
|
|
|
|
+ absDelta = Math.max(Math.abs(deltaY), Math.abs(deltaX));
|
|
|
|
|
|
|
|
- if ( !lowestDelta || absDelta < lowestDelta ) {
|
|
|
|
|
|
|
+ if (!lowestDelta || absDelta < lowestDelta) {
|
|
|
lowestDelta = absDelta;
|
|
lowestDelta = absDelta;
|
|
|
|
|
|
|
|
// Adjust older deltas if necessary
|
|
// Adjust older deltas if necessary
|
|
|
- if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
|
|
|
|
|
|
|
+ if (shouldAdjustOldDeltas(orgEvent, absDelta)) {
|
|
|
lowestDelta /= 40;
|
|
lowestDelta /= 40;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Adjust older deltas if necessary
|
|
// Adjust older deltas if necessary
|
|
|
- if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
|
|
|
|
|
|
|
+ if (shouldAdjustOldDeltas(orgEvent, absDelta)) {
|
|
|
// Divide all the things by 40!
|
|
// Divide all the things by 40!
|
|
|
- delta /= 40;
|
|
|
|
|
|
|
+ delta /= 40;
|
|
|
deltaX /= 40;
|
|
deltaX /= 40;
|
|
|
deltaY /= 40;
|
|
deltaY /= 40;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Get a whole, normalized value for the deltas
|
|
// Get a whole, normalized value for the deltas
|
|
|
- delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
|
|
|
|
|
- deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
|
|
|
|
|
- deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
|
|
|
|
|
|
|
+ delta = Math[delta >= 1 ? 'floor' : 'ceil'](delta / lowestDelta);
|
|
|
|
|
+ deltaX = Math[deltaX >= 1 ? 'floor' : 'ceil'](deltaX / lowestDelta);
|
|
|
|
|
+ deltaY = Math[deltaY >= 1 ? 'floor' : 'ceil'](deltaY / lowestDelta);
|
|
|
|
|
|
|
|
// Normalise offsetX and offsetY properties
|
|
// Normalise offsetX and offsetY properties
|
|
|
- if ( special.settings.normalizeOffset && this.getBoundingClientRect ) {
|
|
|
|
|
|
|
+ if (special.settings.normalizeOffset && this.getBoundingClientRect) {
|
|
|
var boundingRect = this.getBoundingClientRect();
|
|
var boundingRect = this.getBoundingClientRect();
|
|
|
offsetX = event.clientX - boundingRect.left;
|
|
offsetX = event.clientX - boundingRect.left;
|
|
|
offsetY = event.clientY - boundingRect.top;
|
|
offsetY = event.clientY - boundingRect.top;
|
|
@@ -238,7 +237,7 @@
|
|
|
(function($, undefined) {
|
|
(function($, undefined) {
|
|
|
'use strict';
|
|
'use strict';
|
|
|
|
|
|
|
|
- var loadDataSourceFromTable = function ($table) {
|
|
|
|
|
|
|
+ var loadDataSourceFromTable = function($table) {
|
|
|
var cols = [];
|
|
var cols = [];
|
|
|
$table.find('thead>tr:first>th').each(function(idx) {
|
|
$table.find('thead>tr:first>th').each(function(idx) {
|
|
|
var $th = $(this);
|
|
var $th = $(this);
|
|
@@ -291,12 +290,11 @@
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- var DEFAULT_CONFIGS = {
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ var DEFAULT_CONFIGS = {};
|
|
|
|
|
|
|
|
var DEFAULT_PAGER = {
|
|
var DEFAULT_PAGER = {
|
|
|
- page: 0, // current page index
|
|
|
|
|
- recTotal: 0, // records total count
|
|
|
|
|
|
|
+ page: 0, // current page index
|
|
|
|
|
+ recTotal: 0, // records total count
|
|
|
recPerPage: 10, // records count per page
|
|
recPerPage: 10, // records count per page
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -319,7 +317,8 @@
|
|
|
var DEFAULT_SEARCH_FUNC = function(item, searchKeyArr) {
|
|
var DEFAULT_SEARCH_FUNC = function(item, searchKeyArr) {
|
|
|
var score = 0;
|
|
var score = 0;
|
|
|
var searchKeyLength = searchKeyArr.length;
|
|
var searchKeyLength = searchKeyArr.length;
|
|
|
- var matchKeysCount = 0, matchKeys = {};
|
|
|
|
|
|
|
+ var matchKeysCount = 0,
|
|
|
|
|
+ matchKeys = {};
|
|
|
$.each(item, function(key, value) {
|
|
$.each(item, function(key, value) {
|
|
|
var valueType = typeof value;
|
|
var valueType = typeof value;
|
|
|
if (valueType === 'number' || valueType === 'number') {
|
|
if (valueType === 'number' || valueType === 'number') {
|
|
@@ -328,7 +327,7 @@
|
|
|
value = JSON.stringify(valueType);
|
|
value = JSON.stringify(valueType);
|
|
|
}
|
|
}
|
|
|
var keyScore = 0;
|
|
var keyScore = 0;
|
|
|
- for(var i = 0; i < searchKeyLength; ++i) {
|
|
|
|
|
|
|
+ for (var i = 0; i < searchKeyLength; ++i) {
|
|
|
var search = searchKeyArr[i];
|
|
var search = searchKeyArr[i];
|
|
|
if (value.includes(search)) {
|
|
if (value.includes(search)) {
|
|
|
if (value.startsWith(search)) {
|
|
if (value.startsWith(search)) {
|
|
@@ -374,20 +373,20 @@
|
|
|
|
|
|
|
|
// The datagrid modal class
|
|
// The datagrid modal class
|
|
|
var DataGrid = function(element, options) {
|
|
var DataGrid = function(element, options) {
|
|
|
- var that = this;
|
|
|
|
|
- var $element = that.$ = $(element);
|
|
|
|
|
- that.name = NAME;
|
|
|
|
|
- that.uuid = $.zui.uuid();
|
|
|
|
|
- that.id = 'zui-datagrid-' + that.uuid;
|
|
|
|
|
- options = $.extend({}, DataGrid.DEFAULTS, that.$.data(), options);
|
|
|
|
|
|
|
+ var that = this;
|
|
|
|
|
+ var $element = that.$ = $(element);
|
|
|
|
|
+ that.name = NAME;
|
|
|
|
|
+ that.uuid = $.zui.uuid();
|
|
|
|
|
+ that.id = 'zui-datagrid-' + that.uuid;
|
|
|
|
|
+ options = $.extend({}, DataGrid.DEFAULTS, that.$.data(), options);
|
|
|
|
|
|
|
|
- var lang = options.lang || 'zh_cn';
|
|
|
|
|
- that.lang = $.isPlainObject(lang) ? ($.extend(true, {}, LANG[lang.lang || $.zui.clientLang()], lang)) : LANG[lang];
|
|
|
|
|
|
|
+ var lang = options.lang || 'zh_cn';
|
|
|
|
|
+ that.lang = $.isPlainObject(lang) ? ($.extend(true, {}, LANG[lang.lang || $.zui.clientLang()], lang)) : LANG[lang];
|
|
|
|
|
|
|
|
- options.valueOperator = $.extend({}, DEFAULT_VALUE_OPERATOR, options.valueOperator);
|
|
|
|
|
|
|
+ options.valueOperator = $.extend({}, DEFAULT_VALUE_OPERATOR, options.valueOperator);
|
|
|
options.rowDefaultHeight = options.rowDefaultHeight || 30;
|
|
options.rowDefaultHeight = options.rowDefaultHeight || 30;
|
|
|
- options.headerHeight = options.headerHeight || options.rowDefaultHeight || 30;
|
|
|
|
|
- that.options = options;
|
|
|
|
|
|
|
+ options.headerHeight = options.headerHeight || options.rowDefaultHeight || 30;
|
|
|
|
|
+ that.options = options;
|
|
|
if (typeof options.borderWidth !== 'number') {
|
|
if (typeof options.borderWidth !== 'number') {
|
|
|
options.borderWidth = 1;
|
|
options.borderWidth = 1;
|
|
|
}
|
|
}
|
|
@@ -404,7 +403,7 @@
|
|
|
$container = $('<div class="datagrid-container" />').appendTo($element);
|
|
$container = $('<div class="datagrid-container" />').appendTo($element);
|
|
|
}
|
|
}
|
|
|
$container.css({
|
|
$container.css({
|
|
|
- width: options.width,
|
|
|
|
|
|
|
+ width: options.width,
|
|
|
borderWidth: options.borderWidth
|
|
borderWidth: options.borderWidth
|
|
|
});
|
|
});
|
|
|
var $document = $(document);
|
|
var $document = $(document);
|
|
@@ -430,7 +429,7 @@
|
|
|
if (isClickBar) {
|
|
if (isClickBar) {
|
|
|
offset = (lastPos - startPagePos) + startScrollOffset;
|
|
offset = (lastPos - startPagePos) + startScrollOffset;
|
|
|
} else {
|
|
} else {
|
|
|
- offset = Math.max(0, Math.min(scroll.space, pos - Math.round(scroll.barSize/2)));
|
|
|
|
|
|
|
+ offset = Math.max(0, Math.min(scroll.space, pos - Math.round(scroll.barSize / 2)));
|
|
|
}
|
|
}
|
|
|
if (direction === 'h') {
|
|
if (direction === 'h') {
|
|
|
that.setScrollbarOffset(offset);
|
|
that.setScrollbarOffset(offset);
|
|
@@ -479,22 +478,22 @@
|
|
|
$cells = $('<div class="datagrid-cells" />').appendTo($container);
|
|
$cells = $('<div class="datagrid-cells" />').appendTo($container);
|
|
|
}
|
|
}
|
|
|
$cells.toggleClass('datagrid-hover-cell', !!options.hoverCell)
|
|
$cells.toggleClass('datagrid-hover-cell', !!options.hoverCell)
|
|
|
- .toggleClass('datagrid-hover-row', !!options.hoverRow)
|
|
|
|
|
- .toggleClass('datagrid-hover-col', !!options.hoverCol)
|
|
|
|
|
- .toggleClass('datagrid-hover-shadow', !!options.hoverCol);
|
|
|
|
|
|
|
+ .toggleClass('datagrid-hover-row', !!options.hoverRow)
|
|
|
|
|
+ .toggleClass('datagrid-hover-col', !!options.hoverCol)
|
|
|
|
|
+ .toggleClass('datagrid-hover-shadow', !!options.hoverCol);
|
|
|
that.$cells = $cells;
|
|
that.$cells = $cells;
|
|
|
|
|
|
|
|
// configs is an object
|
|
// configs is an object
|
|
|
that.isFuncConfigs = $.isFunction(options.configs);
|
|
that.isFuncConfigs = $.isFunction(options.configs);
|
|
|
that.configs = that.isFuncConfigs ? options.configs : $.extend({}, DEFAULT_CONFIGS, options.configs);
|
|
that.configs = that.isFuncConfigs ? options.configs : $.extend({}, DEFAULT_CONFIGS, options.configs);
|
|
|
|
|
|
|
|
- that.layout = {scrollLeft: 0, scrollTop: 0};
|
|
|
|
|
|
|
+ that.layout = { scrollLeft: 0, scrollTop: 0 };
|
|
|
that.configsCache = {};
|
|
that.configsCache = {};
|
|
|
- that.userConfigs = {};
|
|
|
|
|
|
|
+ that.userConfigs = {};
|
|
|
|
|
|
|
|
// states is 2D arrays
|
|
// states is 2D arrays
|
|
|
- that.states = $.extend(true, {}, DEFAULT_STATES, options.states);
|
|
|
|
|
- that.cells = [];
|
|
|
|
|
|
|
+ that.states = $.extend(true, {}, DEFAULT_STATES, options.states);
|
|
|
|
|
+ that.cells = [];
|
|
|
that.setPager(that.states.pager);
|
|
that.setPager(that.states.pager);
|
|
|
|
|
|
|
|
that.setDataSource(options.dataSource);
|
|
that.setDataSource(options.dataSource);
|
|
@@ -581,9 +580,9 @@
|
|
|
// Init searchbox
|
|
// Init searchbox
|
|
|
if ($.fn.searchBox) {
|
|
if ($.fn.searchBox) {
|
|
|
var $searchBox = that.$.find('.search-box');
|
|
var $searchBox = that.$.find('.search-box');
|
|
|
- if($searchBox) {
|
|
|
|
|
|
|
+ if ($searchBox) {
|
|
|
that.searchbox = $searchBox.searchBox({
|
|
that.searchbox = $searchBox.searchBox({
|
|
|
- onSearchChange: function (searchString) {
|
|
|
|
|
|
|
+ onSearchChange: function(searchString) {
|
|
|
that.search(searchString);
|
|
that.search(searchString);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -676,7 +675,7 @@
|
|
|
dataSource.array = data;
|
|
dataSource.array = data;
|
|
|
dataSource.length = data.length;
|
|
dataSource.length = data.length;
|
|
|
that.setPager('', data.length);
|
|
that.setPager('', data.length);
|
|
|
- } else if ($.isPlainObject(data)) {
|
|
|
|
|
|
|
+ } else if ($.isPlainObject(data)) {
|
|
|
dataSource = $.extend(dataSource, data);
|
|
dataSource = $.extend(dataSource, data);
|
|
|
} else if (typeof data === 'string') {
|
|
} else if (typeof data === 'string') {
|
|
|
dataSource.remote = data;
|
|
dataSource.remote = data;
|
|
@@ -703,7 +702,7 @@
|
|
|
for (var i = 0; i < cols.length; ++i) {
|
|
for (var i = 0; i < cols.length; ++i) {
|
|
|
var col = cols[i];
|
|
var col = cols[i];
|
|
|
if (typeof col === 'string') {
|
|
if (typeof col === 'string') {
|
|
|
- cols[i] = {name: col};
|
|
|
|
|
|
|
+ cols[i] = { name: col };
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -765,11 +764,11 @@
|
|
|
var that = this;
|
|
var that = this;
|
|
|
var states = that.states;
|
|
var states = that.states;
|
|
|
return {
|
|
return {
|
|
|
- page: that.pager.page,
|
|
|
|
|
|
|
+ page: that.pager.page,
|
|
|
recPerPage: that.pager.recPerPage,
|
|
recPerPage: that.pager.recPerPage,
|
|
|
- search: states.search,
|
|
|
|
|
- sortBy: states.sortBy,
|
|
|
|
|
- order: states.order
|
|
|
|
|
|
|
+ search: states.search,
|
|
|
|
|
+ sortBy: states.sortBy,
|
|
|
|
|
+ order: states.order
|
|
|
};
|
|
};
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -803,7 +802,7 @@
|
|
|
var remote = dataSource.remote;
|
|
var remote = dataSource.remote;
|
|
|
if (!loadData && remote) {
|
|
if (!loadData && remote) {
|
|
|
loadData = function(params, onFinish) {
|
|
loadData = function(params, onFinish) {
|
|
|
- var ajaxOptions = $.isFunction(remote) ? remote(params, that) : {url: remote};
|
|
|
|
|
|
|
+ var ajaxOptions = $.isFunction(remote) ? remote(params, that) : { url: remote };
|
|
|
$.ajax($.extend({
|
|
$.ajax($.extend({
|
|
|
type: 'GET',
|
|
type: 'GET',
|
|
|
data: params,
|
|
data: params,
|
|
@@ -971,7 +970,7 @@
|
|
|
height: layout.headerHeight
|
|
height: layout.headerHeight
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
- var rowHeight = layout.rowHeight;
|
|
|
|
|
|
|
+ var rowHeight = layout.rowHeight;
|
|
|
return {
|
|
return {
|
|
|
height: rowHeight,
|
|
height: rowHeight,
|
|
|
top: layout.headerHeight + (rowIndex > 1 ? ((rowIndex - 1) * rowHeight) : 0) + rowIndex * layout.borderWidth
|
|
top: layout.headerHeight + (rowIndex > 1 ? ((rowIndex - 1) * rowHeight) : 0) + rowIndex * layout.borderWidth
|
|
@@ -979,15 +978,15 @@
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
DataGrid.prototype.updateLayout = function() {
|
|
DataGrid.prototype.updateLayout = function() {
|
|
|
- var that = this;
|
|
|
|
|
- var options = that.options;
|
|
|
|
|
- var layout = that.layout;
|
|
|
|
|
- var data = that.data;
|
|
|
|
|
- var pager = that.pager;
|
|
|
|
|
- var dataLength = pager.pageRecCount;
|
|
|
|
|
- var $container = that.$container;
|
|
|
|
|
- var containerWidth = $container.width();
|
|
|
|
|
- var dataSource = that.dataSource;
|
|
|
|
|
|
|
+ var that = this;
|
|
|
|
|
+ var options = that.options;
|
|
|
|
|
+ var layout = that.layout;
|
|
|
|
|
+ var data = that.data;
|
|
|
|
|
+ var pager = that.pager;
|
|
|
|
|
+ var dataLength = pager.pageRecCount;
|
|
|
|
|
+ var $container = that.$container;
|
|
|
|
|
+ var containerWidth = $container.width();
|
|
|
|
|
+ var dataSource = that.dataSource;
|
|
|
|
|
|
|
|
if (!dataSource.cols.length && dataLength) {
|
|
if (!dataSource.cols.length && dataLength) {
|
|
|
$.each(that.getDataItem(0), function(name) {
|
|
$.each(that.getDataItem(0), function(name) {
|
|
@@ -999,21 +998,21 @@
|
|
|
|
|
|
|
|
// Caculate cols layout
|
|
// Caculate cols layout
|
|
|
if (!layout.cols) {
|
|
if (!layout.cols) {
|
|
|
- var cols = dataSource.cols;
|
|
|
|
|
- var colAutoMinWidth = options.colAutoMinWidth;
|
|
|
|
|
|
|
+ var cols = dataSource.cols;
|
|
|
|
|
+ var colAutoMinWidth = options.colAutoMinWidth;
|
|
|
var colAutoDefaultWidth = options.colAutoDefaultWidth;
|
|
var colAutoDefaultWidth = options.colAutoDefaultWidth;
|
|
|
- var growTotal = 0;
|
|
|
|
|
- var minGrowWidth = 0;
|
|
|
|
|
- var rowIndexWidth = options.rowIndexWidth;
|
|
|
|
|
- var colsLayout = [{
|
|
|
|
|
|
|
+ var growTotal = 0;
|
|
|
|
|
+ var minGrowWidth = 0;
|
|
|
|
|
+ var rowIndexWidth = options.rowIndexWidth;
|
|
|
|
|
+ var colsLayout = [{
|
|
|
left: 0,
|
|
left: 0,
|
|
|
width: options.showRowIndex ? (rowIndexWidth === 'auto' ? ((dataLength + that.pager.skip + '').length * 8 + 18) : rowIndexWidth) : 0
|
|
width: options.showRowIndex ? (rowIndexWidth === 'auto' ? ((dataLength + that.pager.skip + '').length * 8 + 18) : rowIndexWidth) : 0
|
|
|
}];
|
|
}];
|
|
|
- var cellsTotalWidth = 0;
|
|
|
|
|
- var fixedWidth = colsLayout[0].width;
|
|
|
|
|
- var lastGrowColIndex = false;
|
|
|
|
|
- var lastMaxGrow = 0;
|
|
|
|
|
- var checkBoxColIndex = 0;
|
|
|
|
|
|
|
+ var cellsTotalWidth = 0;
|
|
|
|
|
+ var fixedWidth = colsLayout[0].width;
|
|
|
|
|
+ var lastGrowColIndex = false;
|
|
|
|
|
+ var lastMaxGrow = 0;
|
|
|
|
|
+ var checkBoxColIndex = 0;
|
|
|
var colLayout, colWidth;
|
|
var colLayout, colWidth;
|
|
|
|
|
|
|
|
for (var i = 0; i < cols.length; ++i) {
|
|
for (var i = 0; i < cols.length; ++i) {
|
|
@@ -1023,13 +1022,13 @@
|
|
|
if (!colWidth || colWidth === 'auto') {
|
|
if (!colWidth || colWidth === 'auto') {
|
|
|
colWidth = 0.1;
|
|
colWidth = 0.1;
|
|
|
}
|
|
}
|
|
|
- colLayout = {left: 0};
|
|
|
|
|
|
|
+ colLayout = { left: 0 };
|
|
|
if (colWidth >= 1) {
|
|
if (colWidth >= 1) {
|
|
|
if (col.minWidth !== undefined) {
|
|
if (col.minWidth !== undefined) {
|
|
|
colWidth = Math.max(colWidth, col.minWidth);
|
|
colWidth = Math.max(colWidth, col.minWidth);
|
|
|
}
|
|
}
|
|
|
colLayout.width = colWidth;
|
|
colLayout.width = colWidth;
|
|
|
- fixedWidth += colWidth;
|
|
|
|
|
|
|
+ fixedWidth += colWidth;
|
|
|
} else {
|
|
} else {
|
|
|
if (col.minWidth === undefined) {
|
|
if (col.minWidth === undefined) {
|
|
|
col.minWidth = colAutoMinWidth;
|
|
col.minWidth = colAutoMinWidth;
|
|
@@ -1038,13 +1037,13 @@
|
|
|
growTotal += colWidth;
|
|
growTotal += colWidth;
|
|
|
minGrowWidth += col.minWidth;
|
|
minGrowWidth += col.minWidth;
|
|
|
if (lastMaxGrow <= colLayout.grow) {
|
|
if (lastMaxGrow <= colLayout.grow) {
|
|
|
- lastMaxGrow = colLayout.grow;
|
|
|
|
|
|
|
+ lastMaxGrow = colLayout.grow;
|
|
|
lastGrowColIndex = i + 1;
|
|
lastGrowColIndex = i + 1;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
colLayout.minWidth = col.minWidth;
|
|
colLayout.minWidth = col.minWidth;
|
|
|
if (!checkBoxColIndex && col.checkbox) {
|
|
if (!checkBoxColIndex && col.checkbox) {
|
|
|
- checkBoxColIndex = i + 1;
|
|
|
|
|
|
|
+ checkBoxColIndex = i + 1;
|
|
|
colLayout.checkbox = true;
|
|
colLayout.checkbox = true;
|
|
|
}
|
|
}
|
|
|
colsLayout.push(colLayout);
|
|
colsLayout.push(colLayout);
|
|
@@ -1056,9 +1055,9 @@
|
|
|
fixedWidth += 30;
|
|
fixedWidth += 30;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- var flexWidth = containerWidth - fixedWidth;
|
|
|
|
|
|
|
+ var flexWidth = containerWidth - fixedWidth;
|
|
|
var autoOverflow = flexWidth < minGrowWidth;
|
|
var autoOverflow = flexWidth < minGrowWidth;
|
|
|
- var colsLenght = colsLayout.length;
|
|
|
|
|
|
|
+ var colsLenght = colsLayout.length;
|
|
|
for (var j = 0; j < colsLenght; ++j) {
|
|
for (var j = 0; j < colsLenght; ++j) {
|
|
|
colLayout = colsLayout[j];
|
|
colLayout = colsLayout[j];
|
|
|
colWidth = colLayout.width;
|
|
colWidth = colLayout.width;
|
|
@@ -1087,14 +1086,14 @@
|
|
|
layout.cols = colsLayout;
|
|
layout.cols = colsLayout;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- layout.containerWidth = containerWidth;
|
|
|
|
|
- layout.rowHeight = options.rowDefaultHeight;
|
|
|
|
|
- layout.borderWidth = options.borderWidth;
|
|
|
|
|
- layout.headerHeight = options.showHeader ? (options.headerHeight) : 0;
|
|
|
|
|
- layout.rowsLength = dataLength + 1;
|
|
|
|
|
- layout.colsLength = layout.cols.length;
|
|
|
|
|
- layout.height = layout.headerHeight + dataLength * (layout.rowHeight + layout.borderWidth);
|
|
|
|
|
- layout.spanMap = {};
|
|
|
|
|
|
|
+ layout.containerWidth = containerWidth;
|
|
|
|
|
+ layout.rowHeight = options.rowDefaultHeight;
|
|
|
|
|
+ layout.borderWidth = options.borderWidth;
|
|
|
|
|
+ layout.headerHeight = options.showHeader ? (options.headerHeight) : 0;
|
|
|
|
|
+ layout.rowsLength = dataLength + 1;
|
|
|
|
|
+ layout.colsLength = layout.cols.length;
|
|
|
|
|
+ layout.height = layout.headerHeight + dataLength * (layout.rowHeight + layout.borderWidth);
|
|
|
|
|
+ layout.spanMap = {};
|
|
|
|
|
|
|
|
var containerHeight = options.height;
|
|
var containerHeight = options.height;
|
|
|
if (containerHeight === 'page') {
|
|
if (containerHeight === 'page') {
|
|
@@ -1103,8 +1102,8 @@
|
|
|
$container.css('height', containerHeight);
|
|
$container.css('height', containerHeight);
|
|
|
layout.containerHeight = containerHeight;
|
|
layout.containerHeight = containerHeight;
|
|
|
|
|
|
|
|
- layout.vScrollSpare = layout.height - layout.containerHeight;
|
|
|
|
|
- layout.hScrollSpare = layout.width - layout.containerWidth;
|
|
|
|
|
|
|
+ layout.vScrollSpare = layout.height - layout.containerHeight;
|
|
|
|
|
+ layout.hScrollSpare = layout.width - layout.containerWidth;
|
|
|
|
|
|
|
|
that.layout = layout;
|
|
that.layout = layout;
|
|
|
|
|
|
|
@@ -1124,8 +1123,8 @@
|
|
|
var cell = {
|
|
var cell = {
|
|
|
rowIndex: rowIndex,
|
|
rowIndex: rowIndex,
|
|
|
colIndex: colIndex,
|
|
colIndex: colIndex,
|
|
|
- config: config,
|
|
|
|
|
- checked: that.isRowChecked(config.rowId)
|
|
|
|
|
|
|
+ config: config,
|
|
|
|
|
+ checked: that.isRowChecked(config.rowId)
|
|
|
};
|
|
};
|
|
|
if (colIndex === 0) {
|
|
if (colIndex === 0) {
|
|
|
type = 'index';
|
|
type = 'index';
|
|
@@ -1167,8 +1166,8 @@
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
DataGrid.prototype.getRowConfig = function(rowIndex) {
|
|
DataGrid.prototype.getRowConfig = function(rowIndex) {
|
|
|
- var that = this;
|
|
|
|
|
- var rowId = 'R' + rowIndex;
|
|
|
|
|
|
|
+ var that = this;
|
|
|
|
|
+ var rowId = 'R' + rowIndex;
|
|
|
var config = that.configsCache[rowId];
|
|
var config = that.configsCache[rowId];
|
|
|
if (!config) {
|
|
if (!config) {
|
|
|
config = $.extend({
|
|
config = $.extend({
|
|
@@ -1200,8 +1199,7 @@
|
|
|
// var config = that.configsCache[colId];
|
|
// var config = that.configsCache[colId];
|
|
|
var config = null;
|
|
var config = null;
|
|
|
if (!config) {
|
|
if (!config) {
|
|
|
- config = $.extend(
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ config = $.extend({
|
|
|
// html: false,
|
|
// html: false,
|
|
|
// style: null,
|
|
// style: null,
|
|
|
// className: '',
|
|
// className: '',
|
|
@@ -1225,8 +1223,7 @@
|
|
|
// var config = that.configsCache[cellId];
|
|
// var config = that.configsCache[cellId];
|
|
|
var config = null;
|
|
var config = null;
|
|
|
if (!config) {
|
|
if (!config) {
|
|
|
- config = $.extend(
|
|
|
|
|
- {id: cellId},
|
|
|
|
|
|
|
+ config = $.extend({ id: cellId },
|
|
|
that.getColConfig(colIndex),
|
|
that.getColConfig(colIndex),
|
|
|
that.getRowConfig(rowIndex),
|
|
that.getRowConfig(rowIndex),
|
|
|
that.isFuncConfigs ? that.configs(cellId) : that.configs[cellId],
|
|
that.isFuncConfigs ? that.configs(cellId) : that.configs[cellId],
|
|
@@ -1242,10 +1239,10 @@
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
DataGrid.prototype.checkRow = function(rowIndex, checked) {
|
|
DataGrid.prototype.checkRow = function(rowIndex, checked) {
|
|
|
- var that = this;
|
|
|
|
|
|
|
+ var that = this;
|
|
|
var selections = that.states.selections;
|
|
var selections = that.states.selections;
|
|
|
- var rowConfig = that.getRowConfig(rowIndex);
|
|
|
|
|
- var rowId = rowConfig.rowId;
|
|
|
|
|
|
|
+ var rowConfig = that.getRowConfig(rowIndex);
|
|
|
|
|
+ var rowId = rowConfig.rowId;
|
|
|
if (checked === undefined) {
|
|
if (checked === undefined) {
|
|
|
checked = !selections[rowId];
|
|
checked = !selections[rowId];
|
|
|
}
|
|
}
|
|
@@ -1281,29 +1278,29 @@
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
DataGrid.prototype.renderCell = function(rowIndex, colIndex, $row) {
|
|
DataGrid.prototype.renderCell = function(rowIndex, colIndex, $row) {
|
|
|
- var that = this;
|
|
|
|
|
- var options = that.options;
|
|
|
|
|
- var cell = that.getCell(rowIndex, colIndex);
|
|
|
|
|
- var config = cell.config;
|
|
|
|
|
|
|
+ var that = this;
|
|
|
|
|
+ var options = that.options;
|
|
|
|
|
+ var cell = that.getCell(rowIndex, colIndex);
|
|
|
|
|
+ var config = cell.config;
|
|
|
|
|
|
|
|
if (cell.hidden) {
|
|
if (cell.hidden) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var isCheckbox = config.checkbox;
|
|
var isCheckbox = config.checkbox;
|
|
|
- var elementId = [that.id, 'cell', rowIndex, colIndex].join('-');
|
|
|
|
|
- var $cell = $('#' + elementId);
|
|
|
|
|
|
|
+ var elementId = [that.id, 'cell', rowIndex, colIndex].join('-');
|
|
|
|
|
+ var $cell = $('#' + elementId);
|
|
|
if (!$cell.length) {
|
|
if (!$cell.length) {
|
|
|
$row = $row || $('#' + that.id + '-row-' + rowIndex);
|
|
$row = $row || $('#' + that.id + '-row-' + rowIndex);
|
|
|
$cell = (options.cellCreator ? options.cellCreator(cell, that) : $('<div class="datagrid-cell" />')).appendTo($row);
|
|
$cell = (options.cellCreator ? options.cellCreator(cell, that) : $('<div class="datagrid-cell" />')).appendTo($row);
|
|
|
$cell.attr({
|
|
$cell.attr({
|
|
|
- id: elementId,
|
|
|
|
|
- 'data-type': cell.type,
|
|
|
|
|
- 'data-col': cell.colIndex,
|
|
|
|
|
- 'data-row': cell.rowIndex
|
|
|
|
|
- }).toggleClass('datagrid-cell-head', rowIndex === 0)
|
|
|
|
|
- .toggleClass('datagrid-cell-cell', cell.type === 'cell')
|
|
|
|
|
- .toggleClass('datagrid-cell-index', colIndex === 0);
|
|
|
|
|
|
|
+ id: elementId,
|
|
|
|
|
+ 'data-type': cell.type,
|
|
|
|
|
+ 'data-col': cell.colIndex,
|
|
|
|
|
+ 'data-row': cell.rowIndex
|
|
|
|
|
+ }).toggleClass('datagrid-cell-head', rowIndex === 0)
|
|
|
|
|
+ .toggleClass('datagrid-cell-cell', cell.type === 'cell')
|
|
|
|
|
+ .toggleClass('datagrid-cell-index', colIndex === 0);
|
|
|
|
|
|
|
|
if (isCheckbox) {
|
|
if (isCheckbox) {
|
|
|
var $checkbox = $cell.find('.datagrid-checkbox');
|
|
var $checkbox = $cell.find('.datagrid-checkbox');
|
|
@@ -1315,9 +1312,9 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Caculate cell style
|
|
// Caculate cell style
|
|
|
- var borderWidth = options.borderWidth;
|
|
|
|
|
- var layout = that.layout;
|
|
|
|
|
- var colsLength = layout.colsLength;
|
|
|
|
|
|
|
+ var borderWidth = options.borderWidth;
|
|
|
|
|
+ var layout = that.layout;
|
|
|
|
|
+ var colsLength = layout.colsLength;
|
|
|
var cellBoundsStyle = {
|
|
var cellBoundsStyle = {
|
|
|
top: borderWidth ? -borderWidth : 0,
|
|
top: borderWidth ? -borderWidth : 0,
|
|
|
bottom: borderWidth ? -borderWidth : 0,
|
|
bottom: borderWidth ? -borderWidth : 0,
|
|
@@ -1365,7 +1362,7 @@
|
|
|
$cell.addClass('datagrid-col-sortable');
|
|
$cell.addClass('datagrid-col-sortable');
|
|
|
}
|
|
}
|
|
|
$sorter.toggleClass('datagrid-sort-up', sorted === 'up')
|
|
$sorter.toggleClass('datagrid-sort-up', sorted === 'up')
|
|
|
- .toggleClass('datagrid-sort-down', sorted === 'down');
|
|
|
|
|
|
|
+ .toggleClass('datagrid-sort-down', sorted === 'down');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (isCheckbox) {
|
|
if (isCheckbox) {
|
|
@@ -1376,25 +1373,25 @@
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
DataGrid.prototype.renderRow = function(rowIndex) {
|
|
DataGrid.prototype.renderRow = function(rowIndex) {
|
|
|
- var that = this;
|
|
|
|
|
- var layout = that.layout;
|
|
|
|
|
- var options = that.options;
|
|
|
|
|
- var rowLayout = that.getRowLayout(rowIndex);
|
|
|
|
|
|
|
+ var that = this;
|
|
|
|
|
+ var layout = that.layout;
|
|
|
|
|
+ var options = that.options;
|
|
|
|
|
+ var rowLayout = that.getRowLayout(rowIndex);
|
|
|
var colsLength = layout.colsLength;
|
|
var colsLength = layout.colsLength;
|
|
|
- var elementId = that.id + '-row-' + rowIndex;
|
|
|
|
|
- var $row = $('#' + elementId);
|
|
|
|
|
|
|
+ var elementId = that.id + '-row-' + rowIndex;
|
|
|
|
|
+ var $row = $('#' + elementId);
|
|
|
if (!$row.length) {
|
|
if (!$row.length) {
|
|
|
$row = (options.rowCreator ? options.rowCreator(rowIndex, that) : $('<div class="datagrid-row" />')).appendTo(that.$cells);
|
|
$row = (options.rowCreator ? options.rowCreator(rowIndex, that) : $('<div class="datagrid-row" />')).appendTo(that.$cells);
|
|
|
$row.attr({
|
|
$row.attr({
|
|
|
- id: elementId,
|
|
|
|
|
- 'data-row': rowIndex,
|
|
|
|
|
- 'data-id': rowIndex
|
|
|
|
|
- }).css({
|
|
|
|
|
- top: layout.partialRendering ? (rowLayout.top - layout.scrollTop) : rowLayout.top,
|
|
|
|
|
- height: rowLayout.height
|
|
|
|
|
- }).toggleClass('datagrid-row-head', rowIndex === 0)
|
|
|
|
|
- .toggleClass('datagrid-row-cell', rowIndex !== 0);
|
|
|
|
|
- } else if(layout.partialRendering) {
|
|
|
|
|
|
|
+ id: elementId,
|
|
|
|
|
+ 'data-row': rowIndex,
|
|
|
|
|
+ 'data-id': rowIndex
|
|
|
|
|
+ }).css({
|
|
|
|
|
+ top: layout.partialRendering ? (rowLayout.top - layout.scrollTop) : rowLayout.top,
|
|
|
|
|
+ height: rowLayout.height
|
|
|
|
|
+ }).toggleClass('datagrid-row-head', rowIndex === 0)
|
|
|
|
|
+ .toggleClass('datagrid-row-cell', rowIndex !== 0);
|
|
|
|
|
+ } else if (layout.partialRendering) {
|
|
|
$row.css('top', rowLayout.top - layout.scrollTop);
|
|
$row.css('top', rowLayout.top - layout.scrollTop);
|
|
|
}
|
|
}
|
|
|
for (var i = 0; i < colsLength; ++i) {
|
|
for (var i = 0; i < colsLength; ++i) {
|
|
@@ -1403,20 +1400,21 @@
|
|
|
return $row;
|
|
return $row;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+
|
|
|
DataGrid.prototype.renderData = function() {
|
|
DataGrid.prototype.renderData = function() {
|
|
|
- var that = this;
|
|
|
|
|
- var layout = that.layout;
|
|
|
|
|
|
|
+ var that = this;
|
|
|
|
|
+ var layout = that.layout;
|
|
|
|
|
|
|
|
if (!layout.cols) {
|
|
if (!layout.cols) {
|
|
|
that.updateLayout();
|
|
that.updateLayout();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var startRenderRow = 1;
|
|
var startRenderRow = 1;
|
|
|
- var endRenderRow = layout.rowsLength - 1;
|
|
|
|
|
|
|
+ var endRenderRow = layout.rowsLength - 1;
|
|
|
if (layout.partialRendering) {
|
|
if (layout.partialRendering) {
|
|
|
var rowHeight = layout.rowHeight + layout.borderWidth;
|
|
var rowHeight = layout.rowHeight + layout.borderWidth;
|
|
|
- startRenderRow = Math.min(endRenderRow, Math.max(1, Math.floor((layout.scrollTop - layout.headerHeight)/rowHeight)));
|
|
|
|
|
- endRenderRow = Math.min(endRenderRow, Math.max(1, Math.ceil((layout.scrollTop + layout.containerHeight - layout.headerHeight)/rowHeight)));
|
|
|
|
|
|
|
+ startRenderRow = Math.min(endRenderRow, Math.max(1, Math.floor((layout.scrollTop - layout.headerHeight) / rowHeight)));
|
|
|
|
|
+ endRenderRow = Math.min(endRenderRow, Math.max(1, Math.ceil((layout.scrollTop + layout.containerHeight - layout.headerHeight) / rowHeight)));
|
|
|
that.$cells.find('.datagrid-row').each(function() {
|
|
that.$cells.find('.datagrid-row').each(function() {
|
|
|
var $row = $(this);
|
|
var $row = $(this);
|
|
|
var rowIndex = $row.data('row');
|
|
var rowIndex = $row.data('row');
|
|
@@ -1424,6 +1422,8 @@
|
|
|
$row.remove();
|
|
$row.remove();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ // console.log("---------------------");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Render header
|
|
// Render header
|
|
@@ -1454,10 +1454,13 @@
|
|
|
if (that.pagerObj) {
|
|
if (that.pagerObj) {
|
|
|
that.pagerObj.set(that.pager);
|
|
that.pagerObj.set(that.pager);
|
|
|
}
|
|
}
|
|
|
|
|
+ if (layout.partialRendering) {
|
|
|
|
|
+ that.$.callComEvent(that, 'onRender');
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
DataGrid.prototype.render = function(ignoreDelay) {
|
|
DataGrid.prototype.render = function(ignoreDelay) {
|
|
|
- var that = this;
|
|
|
|
|
|
|
+ var that = this;
|
|
|
var options = that.options;
|
|
var options = that.options;
|
|
|
|
|
|
|
|
if (!ignoreDelay && options.renderDelay) {
|
|
if (!ignoreDelay && options.renderDelay) {
|
|
@@ -1498,10 +1501,10 @@
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
DataGrid.prototype.setScrollbarOffset = function(offsetX, offsetY) {
|
|
DataGrid.prototype.setScrollbarOffset = function(offsetX, offsetY) {
|
|
|
- var that = this;
|
|
|
|
|
- var layout = that.layout;
|
|
|
|
|
|
|
+ var that = this;
|
|
|
|
|
+ var layout = that.layout;
|
|
|
var scrollLeft = layout.scrollLeft;
|
|
var scrollLeft = layout.scrollLeft;
|
|
|
- var scrollTop = layout.scrollTop;
|
|
|
|
|
|
|
+ var scrollTop = layout.scrollTop;
|
|
|
if (typeof offsetX === 'number') {
|
|
if (typeof offsetX === 'number') {
|
|
|
var hScroll = layout.hScroll;
|
|
var hScroll = layout.hScroll;
|
|
|
if (hScroll.offset !== offsetX) {
|
|
if (hScroll.offset !== offsetX) {
|
|
@@ -1518,10 +1521,10 @@
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
DataGrid.prototype.renderScrolls = function() {
|
|
DataGrid.prototype.renderScrolls = function() {
|
|
|
- var that = this;
|
|
|
|
|
- var layout = that.layout;
|
|
|
|
|
- var vSize = layout.vScrollSpare;
|
|
|
|
|
- var hSize = layout.hScrollSpare;
|
|
|
|
|
|
|
+ var that = this;
|
|
|
|
|
+ var layout = that.layout;
|
|
|
|
|
+ var vSize = layout.vScrollSpare;
|
|
|
|
|
+ var hSize = layout.hScrollSpare;
|
|
|
var showVBar = vSize > 0;
|
|
var showVBar = vSize > 0;
|
|
|
var showHBar = hSize > 0;
|
|
var showHBar = hSize > 0;
|
|
|
that.$vScroll.toggle(showVBar);
|
|
that.$vScroll.toggle(showVBar);
|
|
@@ -1574,7 +1577,7 @@
|
|
|
|
|
|
|
|
DataGrid.prototype.scroll = function(scrollLeft, scrollTop, ignoreDelay) {
|
|
DataGrid.prototype.scroll = function(scrollLeft, scrollTop, ignoreDelay) {
|
|
|
var that = this;
|
|
var that = this;
|
|
|
- var now = new Date();
|
|
|
|
|
|
|
+ var now = new Date();
|
|
|
var scrollDelay = that.options.scrollDelay;
|
|
var scrollDelay = that.options.scrollDelay;
|
|
|
if (scrollDelay) {
|
|
if (scrollDelay) {
|
|
|
if (!ignoreDelay && that.lastScrollTime && (now - that.lastScrollTime) < scrollDelay) {
|
|
if (!ignoreDelay && that.lastScrollTime && (now - that.lastScrollTime) < scrollDelay) {
|
|
@@ -1594,7 +1597,8 @@
|
|
|
that.lastScrollTime = now;
|
|
that.lastScrollTime = now;
|
|
|
}
|
|
}
|
|
|
var layout = that.layout;
|
|
var layout = that.layout;
|
|
|
- var hScrolled = false, vScrolled = false;
|
|
|
|
|
|
|
+ var hScrolled = false,
|
|
|
|
|
+ vScrolled = false;
|
|
|
if (typeof scrollLeft === 'number') {
|
|
if (typeof scrollLeft === 'number') {
|
|
|
scrollLeft = Math.max(0, Math.min(scrollLeft, layout.width - layout.containerWidth));
|
|
scrollLeft = Math.max(0, Math.min(scrollLeft, layout.width - layout.containerWidth));
|
|
|
if (scrollLeft !== layout.scrollLeft) {
|
|
if (scrollLeft !== layout.scrollLeft) {
|
|
@@ -1619,11 +1623,11 @@
|
|
|
that.renderFixeds();
|
|
that.renderFixeds();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- that.$.callComEvent(that, 'onScroll', [scrollLeft, scrollTop, {vScrolled: vScrolled, hScrolled: hScrolled}]);
|
|
|
|
|
|
|
+ that.$.callComEvent(that, 'onScroll', [scrollLeft, scrollTop, { vScrolled: vScrolled, hScrolled: hScrolled }]);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
DataGrid.prototype.renderFixeds = function() {
|
|
DataGrid.prototype.renderFixeds = function() {
|
|
|
- var that = this;
|
|
|
|
|
|
|
+ var that = this;
|
|
|
var states = that.states;
|
|
var states = that.states;
|
|
|
var layout = that.layout;
|
|
var layout = that.layout;
|
|
|
|
|
|
|
@@ -1807,9 +1811,9 @@
|
|
|
var data = $this.data(NAME);
|
|
var data = $this.data(NAME);
|
|
|
var options = typeof option == 'object' && option;
|
|
var options = typeof option == 'object' && option;
|
|
|
|
|
|
|
|
- if(!data) $this.data(NAME, (data = new DataGrid(this, options)));
|
|
|
|
|
|
|
+ if (!data) $this.data(NAME, (data = new DataGrid(this, options)));
|
|
|
|
|
|
|
|
- if(typeof option == 'string') data[option]();
|
|
|
|
|
|
|
+ if (typeof option == 'string') data[option]();
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -1821,5 +1825,4 @@
|
|
|
$(function() {
|
|
$(function() {
|
|
|
$('[data-ride="datagrid"]').datagrid();
|
|
$('[data-ride="datagrid"]').datagrid();
|
|
|
});
|
|
});
|
|
|
-}(jQuery, undefined));
|
|
|
|
|
-
|
|
|
|
|
|
|
+}(jQuery, undefined));
|