correctly compute list height in Ox.List if horizontal scrolling is disabled in Ox.TableList

This commit is contained in:
rolux 2012-09-01 11:46:01 +02:00
parent d16f76f0da
commit 39708edd8b
2 changed files with 21 additions and 7 deletions

View file

@ -5,6 +5,7 @@ Ox.List <f> List constructor
options <o> Options object
centered <b|false> if true, and orientation is 'horizontal', then keep the selected item centered
construct <f|null> (data) returns the list item HTML
disableHorizontalScrolling <b|false> If true, disable scrolling
draggable <b|false> If true, items can be dragged
format <[]> ???
itemHeight <n|16> item height
@ -64,6 +65,7 @@ Ox.List = function(options, self) {
_tree: false,
centered: false,
construct: null,
disableHorizonzalScrolling: false,
draggable: false,
format: [],
itemHeight: 16,
@ -583,7 +585,11 @@ Ox.List = function(options, self) {
}
function getHeight() {
return that.height() - (that.$content.width() > that.width() ? Ox.UI.SCROLLBAR_SIZE : 0);
return that.height() - (
!self.options.disableHorizontalScrolling
&& that.$content.width() > that.width()
? Ox.UI.SCROLLBAR_SIZE : 0
);
}
function getListSize() {

View file

@ -24,6 +24,7 @@ Ox.TableList <f> TableList Widget
columnsResizable <b|false> If true, columns are resizable
columnsVisible <b|false> If true, columns are visible
columnWidth <[n]|[40, 800]> Minimum and maximum column width
disableHorizontalScrolling <b|false> If true, disable scrolling
draggable <b|false> If true, items can be dragged
id <s|''> Id
items <f|null> function() {} {sort, range, keys, callback} or array
@ -107,10 +108,6 @@ Ox.TableList = function(options, self) {
})
.addClass('OxTableList');
if (!self.options.disableHorizontalScrolling) {
enableHorizontalScrolling();
}
self.options.columns.forEach(function(column) { // fixme: can this go into a generic ox.js function?
// fixme: and can't these just remain undefined?
if (Ox.isUndefined(column.align)) {
@ -246,6 +243,7 @@ Ox.TableList = function(options, self) {
that.$body = Ox.List({
construct: constructItem,
disableHorizontalScrolling: self.options.disableHorizontalScrolling,
draggable: self.options.draggable,
id: self.options.id,
itemHeight: 16,
@ -306,6 +304,10 @@ Ox.TableList = function(options, self) {
width: getItemWidth() + 'px'
});
self.options.disableHorizontalScrolling
? disableHorizontalScrolling()
: enableHorizontalScrolling();
//Ox.Log('List', 's.vC', self.visibleColumns)
function addColumn(id) {
@ -520,7 +522,10 @@ Ox.TableList = function(options, self) {
}
function disableHorizontalScrolling() {
that.$body.css({overflowX: 'hidden'});
that.$body.options({
disableHorizontalScrolling: true
})
.css({overflowX: 'hidden'});
// fixme: is there a way to pass an array?
that.unbindEvent('key_left').unbindEvent('key_right');
}
@ -627,7 +632,10 @@ Ox.TableList = function(options, self) {
}
function enableHorizontalScrolling() {
that.$body && that.$body.css({overflowX: 'auto'});
that.$body.options({
disableHorizontalScrolling: false
})
.css({overflowX: 'auto'});
that.bindEvent({
key_left: function () {
var $element = that.$body.$element,