fix setting sort option for text lists w/o column heads

This commit is contained in:
rlx 2011-01-11 12:27:01 +00:00
parent a90fe8c25f
commit e8be24d20e

View file

@ -6934,11 +6934,8 @@ requires
function triggerEditEvent($item, $cell) {
that.triggerEvent('edit', {
id: $item.attr('id'),
key: $cell.attr('class').split('OxColumn')[1].split(' ')[0].toLowerCase(),
// fixme: it'd be nice if we didn't have to pass elements around
item: $item,
cell: $cell
id: $item.data('id'),
key: $cell.attr('class').split('OxColumn')[1].split(' ')[0].toLowerCase()
});
}
@ -7152,10 +7149,13 @@ requires
that.$element = self.options.construct(self.data)
.addClass('OxItem')
.attr({
draggable: self.options.draggable,
id: self.options.id
draggable: self.options.draggable
//id: self.options.id.replace(/./g, '_') // fixme: dots are not the only problem
})
.data('position', self.options.position);
.data({
id: self.options.id,
position: self.options.position
});
return that;
@ -7191,6 +7191,10 @@ requires
.addClass('OxTextList');
$.each(self.options.columns, function(i, v) { // fixme: can this go into a generic ox.js function?
// fixme: and can't these just remain undefined?
if (Ox.isUndefined(v.editable)) {
v.editable = false;
}
if (Ox.isUndefined(v.unique)) {
v.unique = false;
}
@ -7526,14 +7530,15 @@ requires
that.$body.clearCache();
}
function editCell(id, key, $item, $cell) {
function editCell(id, key) {
Ox.print('editCell')
var $input,
var $item = getItem(id),
$cell = getCell(id, key),
$input,
html = $cell.html(),
index = getColumnIndexById(key),
column = self.options.columns[index],
width = column.width;
Ox.print($item, $cell)
$cell.empty()
.addClass('OxEdit')
.css({
@ -7559,6 +7564,7 @@ requires
function submit() {
var value = $input.value();
//$input.loseFocus().remove();
// fixme: leaky, inputs remain in focus stack
$cell.removeClass('OxEdit')
.css({
width: (width - 8) + 'px'
@ -7572,6 +7578,11 @@ requires
}
}
function getCell(id, key) {
var $item = getItem(id);
return $($item.find('.OxCell.OxColumn' + Ox.toTitleCase(key))[0]);
}
function getColumnIndexById(id) {
return Ox.getPositionById(self.options.columns, id);
}
@ -7580,6 +7591,18 @@ requires
return Ox.getPositionById(self.visibleColumns, id);
}
function getItem(id) {
var $item = null;
$.each(that.find('.OxItem'), function(i, v) {
$v = $(v);
if ($v.data('id') == id) {
$item = $v;
return false;
}
})
return $item;
}
function getItemWidth() {
return Math.max(Ox.sum(self.columnWidths), that.$element.width() - oxui.scrollbarSize);
//return Ox.sum(self.columnWidths)
@ -7711,16 +7734,16 @@ requires
that.$body.closePreview();
};
that.size = function() {
setWidth();
that.$body.size();
}
that.resizeColumn = function(id, width) {
resizeColumn(id, width);
return that;
}
that.size = function() {
setWidth();
that.$body.size();
}
that.sortList = function(key, operator) {
var isSelected = key == self.options.sort[0].key;
self.options.sort = [
@ -7729,17 +7752,27 @@ requires
operator: operator
}
];
if (isSelected) {
updateOrder(self.options.columns[self.selectedColumn].id);
} else {
toggleSelected(self.options.columns[self.selectedColumn].id);
self.selectedColumn = getColumnIndexById(key);
toggleSelected(self.options.columns[self.selectedColumn].id);
if (self.options.columnsVisible) {
if (isSelected) {
updateOrder(self.options.columns[self.selectedColumn].id);
} else {
toggleSelected(self.options.columns[self.selectedColumn].id);
self.selectedColumn = getColumnIndexById(key);
toggleSelected(self.options.columns[self.selectedColumn].id);
}
}
that.$body.sortList(self.options.sort[0].key, self.options.sort[0].operator);
return that;
};
that.value = function(id, key, value) {
if (Ox.isUndefined(value)) {
} else {
return that;
}
}
return that;
};