[FIX]Refixed the issue of resequence, added id at specified index in dataset.

bzr revid: msh@openerp.com-20130606065630-r536yqlcq0wihs8l
This commit is contained in:
Mohammed Shekha 2013-06-06 12:26:30 +05:30
commit 2b65ba1f64
2 changed files with 7 additions and 1 deletions

View File

@ -625,6 +625,10 @@ instance.web.DataSet = instance.web.Class.extend(instance.web.PropertiesMixin,
remove_ids: function (ids) {
this.alter_ids(_(this.ids).difference(ids));
},
add_ids: function(ids, at) {
var self = this;
_.each(ids, function(id){ self.ids.splice(at, 0, id); });
},
/**
* Resequence records.
*

View File

@ -896,7 +896,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
this.record_callbacks = {
'remove': function (event, record) {
var id = record.get('id');
self.dataset.remove_ids([id])
self.dataset.remove_ids([id]);
var $row = self.$current.children('[data-id=' + id + ']');
var index = $row.data('index');
$row.remove();
@ -925,6 +925,8 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
},
'add': function (ev, records, record, index) {
var $new_row = $(self.render_record(record));
var id = record.get('id');
self.dataset.add_ids([id], index);
if (index === 0) {
$new_row.prependTo(self.$current);