Ox.TableList: make value method accept (id, {key: value})
This commit is contained in:
parent
a5baff8319
commit
5001a47cf8
1 changed files with 27 additions and 21 deletions
|
@ -1215,31 +1215,37 @@ Ox.TableList = function(options, self) {
|
||||||
(id) -> get values of row id
|
(id) -> get values of row id
|
||||||
(id, key) -> get value of cell id, key
|
(id, key) -> get value of cell id, key
|
||||||
(id, key, value) -> set id, key to value
|
(id, key, value) -> set id, key to value
|
||||||
|
(id, {key: value, ...}) -> set id, keys to values
|
||||||
@*/
|
@*/
|
||||||
that.value = function(id, key, value) {
|
that.value = function() {
|
||||||
// fixme: make this accept id, {k: v, ...}
|
var $cell,
|
||||||
var $cell;
|
args = Ox.slice(arguments),
|
||||||
|
id = args.shift(),
|
||||||
|
sort = false;
|
||||||
if (arguments.length == 1) {
|
if (arguments.length == 1) {
|
||||||
return that.$body.value(id);
|
return that.$body.value(id);
|
||||||
} else if (arguments.length == 2) {
|
} else if (arguments.length == 2 && Ox.isString(arguments[1])) {
|
||||||
return that.$body.value(id, key);
|
return that.$body.value(id, arguments[1]);
|
||||||
} else {
|
} else {
|
||||||
that.$body.value(id, key, value);
|
Ox.forEach(Ox.makeObject(args), function(value, key) {
|
||||||
if (key == self.options.unique) {
|
that.$body.value(id, key, value);
|
||||||
// unique id has changed
|
if (key == self.options.unique) {
|
||||||
self.options.selected = self.options.selected.map(function(id_) {
|
// unique id has changed
|
||||||
return id_ == id ? value : id_
|
self.options.selected = self.options.selected.map(function(id_) {
|
||||||
});
|
return id_ == id ? value : id_
|
||||||
id = value;
|
});
|
||||||
}
|
id = value;
|
||||||
$cell = getCell(id, key);
|
}
|
||||||
if ($cell && !$cell.is('.OxEdit')) {
|
$cell = getCell(id, key);
|
||||||
$cell.html(formatValue(key, value, that.$body.value(id)));
|
if ($cell && !$cell.is('.OxEdit')) {
|
||||||
}
|
$cell.html(formatValue(key, value, that.$body.value(id)));
|
||||||
if (!self.options.sortable && key == self.options.sort[0].key) {
|
}
|
||||||
// sort key has changed
|
if (!self.options.sortable && key == self.options.sort[0].key) {
|
||||||
that.$body.sort();
|
// sort key has changed
|
||||||
}
|
sort = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sort && that.$body.sort();
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue