TableList: don't require 'keys' if 'items' is array

This commit is contained in:
rolux 2012-06-27 20:28:59 +02:00
parent 6e2a837f1c
commit 8296d3c405

View file

@ -108,13 +108,6 @@ Ox.TableList = function(options, self) {
keys: find
});
self.options.sort = self.options.sort.map(function(sort) {
return Ox.isString(sort) ? {
key: sort.replace(/^[\+\-]/, ''),
operator: sort[0] == '-' ? '-' : '+'
} : sort;
});
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)) {
@ -142,6 +135,13 @@ Ox.TableList = function(options, self) {
key: self.options.unique,
operator: Ox.getObjectById(self.options.columns, self.options.unique).operator
}];
} else{
self.options.sort = self.options.sort.map(function(sort) {
return Ox.isString(sort) ? {
key: sort.replace(/^[\+\-]/, ''),
operator: sort[0] == '-' ? '-' : '+'
} : sort;
});
}
Ox.extend(self, {
@ -149,6 +149,7 @@ Ox.TableList = function(options, self) {
defaultColumnWidths: self.options.columns.map(function(column) {
return column.defaultWidth || column.width;
}),
hasItemsArray: Ox.isArray(self.options.items),
itemHeight: 16,
page: 0,
pageLength: 100,
@ -229,7 +230,11 @@ Ox.TableList = function(options, self) {
itemWidth: getItemWidth(),
format: self.format, // fixme: not needed, happens in TableList
keys: Ox.unique(
self.visibleColumns.map(function(column) {
(
self.hasItemsArray
? self.options.columns
: self.visibleColumns
).map(function(column) {
return column.id;
})
.concat(self.options.unique)
@ -296,7 +301,7 @@ Ox.TableList = function(options, self) {
self.columnWidths.splice(index, 0, column.width);
that.$head.$content.empty();
constructHead();
that.$body.options({
!self.hasItemsArray && that.$body.options({
keys: self.visibleColumns.map(function(column) {
return column.id;
}).concat(self.options.keys)
@ -747,7 +752,7 @@ Ox.TableList = function(options, self) {
that.$body.$content.css({
width: itemWidth + 'px'
});
that.$body.options({
!self.hasItemsArray && that.$body.options({
keys: self.visibleColumns.map(function(column) {
return column.id;
}).concat(self.options.keys)