make list preserve selection after reload
This commit is contained in:
parent
23eff70f77
commit
389f65a4d8
|
@ -560,6 +560,7 @@ Lists
|
|||
}
|
||||
.OxTextList .OxBody .OxItem {
|
||||
height: 16px;
|
||||
cursor: default;
|
||||
}
|
||||
.OxTextList .OxBody .OxItem .OxCell {
|
||||
float: left;
|
||||
|
|
|
@ -2391,6 +2391,7 @@ requires
|
|||
$.extend(self, {
|
||||
$items: [],
|
||||
$pages: [],
|
||||
ids: {},
|
||||
page: 0,
|
||||
pageLength: 100,
|
||||
requests: [],
|
||||
|
@ -2399,6 +2400,7 @@ requires
|
|||
|
||||
self.options.request({
|
||||
callback: function(result) {
|
||||
Ox.print("items", result.data.items);
|
||||
$.extend(self, {
|
||||
listHeight: result.data.items * self.options.itemHeight,
|
||||
listLength: result.data.items,
|
||||
|
@ -2408,7 +2410,6 @@ requires
|
|||
pageHeight: self.options.orientation == "horizontal" ? 0 :
|
||||
self.pageLength * self.options.itemHeight / self.options.rowLength
|
||||
});
|
||||
Ox.print("listHeight", self.listHeight)
|
||||
that.$content.css({
|
||||
height: self.listHeight + "px"
|
||||
});
|
||||
|
@ -2499,7 +2500,7 @@ requires
|
|||
function getNext() {
|
||||
var pos = -1;
|
||||
if (self.selected.length) {
|
||||
var pos = Ox.max(self.selected) + 1;
|
||||
pos = Ox.max(self.selected) + 1;
|
||||
if (pos == self.$items.length) {
|
||||
pos = -1;
|
||||
}
|
||||
|
@ -2516,7 +2517,7 @@ requires
|
|||
function getPrevious() {
|
||||
var pos = -1;
|
||||
if (self.selected.length) {
|
||||
var pos = Ox.min(self.selected) - 1;
|
||||
pos = Ox.min(self.selected) - 1;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
@ -2533,7 +2534,7 @@ requires
|
|||
|
||||
function loadPage(page, callback) {
|
||||
Ox.print("loadPage", page)
|
||||
if (page < 0 || page >= self.pages) {
|
||||
if (page < 0 || page >= self.pages) { // fixme: callback doesn't get called
|
||||
return;
|
||||
}
|
||||
var keys = $.inArray("id", self.options.keys) > -1 ? self.options.keys :
|
||||
|
@ -2562,13 +2563,14 @@ requires
|
|||
data: v,
|
||||
position: pos
|
||||
});
|
||||
self.ids[pos] = v.id;
|
||||
if (isSelected(pos)) {
|
||||
self.$items[pos].addClass("OxSelected");
|
||||
}
|
||||
self.$items[pos].appendTo(self.$pages[page])
|
||||
self.$items[pos].appendTo(self.$pages[page]);
|
||||
});
|
||||
self.$pages[page].appendTo(that.$content);
|
||||
Ox.print(page, "self.$pages", self.$pages)
|
||||
callback();
|
||||
},
|
||||
keys: keys,
|
||||
range: range,
|
||||
|
@ -2698,10 +2700,29 @@ requires
|
|||
Ox.Request.cancel(v);
|
||||
});
|
||||
self.requests = [];
|
||||
//unloadPages(self.page);
|
||||
if (self.selected.length) {
|
||||
Ox.print("sort", self.options.sort, "ids", $.map(self.selected, function(v, i) {
|
||||
return self.ids[v];
|
||||
}));
|
||||
self.requests.push(self.options.request({
|
||||
callback: function(result) {
|
||||
self.selected = [];
|
||||
$.each(result.data.positions, function(id, pos) {
|
||||
Ox.print("id", id, "pos", pos)
|
||||
self.selected.push(pos);
|
||||
addToSelection(pos);
|
||||
});
|
||||
},
|
||||
ids: $.map(self.selected, function(v, i) {
|
||||
return self.ids[v];
|
||||
}),
|
||||
sort: self.options.sort
|
||||
}));
|
||||
}
|
||||
$.extend(self, {
|
||||
$items: [],
|
||||
$pages: [],
|
||||
ids: {},
|
||||
page: 0,
|
||||
selected: []
|
||||
});
|
||||
|
@ -2716,7 +2737,7 @@ requires
|
|||
key: key,
|
||||
operator: operator
|
||||
}
|
||||
// trigger sort event
|
||||
// fixme: trigger sort event here
|
||||
that.reload();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ $(function() {
|
|||
id: "id",
|
||||
operator: "+",
|
||||
title: "ID",
|
||||
visible: false,
|
||||
visible: true,
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user