3
votes

is it possible to add duplicate records inside data store ?

var myData = [
{ id : 0, name : "Rec 0", column1 : "0", column2 : "0" },
{ id : 1, name : "Rec 1", column1 : "1", column2 : "1" },
{ id : 2, name : "Rec 2", column1 : "2", column2 : "2" },
{ id : 3, name : "Rec 3", column1 : "3", column2 : "3" },
{ id : 4, name : "Rec 4", column1 : "4", column2 : "4" },
{ id : 5, name : "Rec 5", column1 : "5", column2 : "5" },
{ id : 6, name : "Rec 6", column1 : "6", column2 : "6" },
{ id : 7, name : "Rec 7", column1 : "7", column2 : "7" },
{ id : 8, name : "Rec 8", column1 : "8", column2 : "8" },
{ id : 9, name : "Rec 9", column1 : "9", column2 : "9" }
];


var origine = new Ext.data.Store({
        //autoDestroy: true,
        storeid: 'origineRec',
        id:'origineRec',
        //model: 'DataObject',
        //idIndex: 0,
        fields: ['id','name','column1 ','column2 '],
        data: myData 
});

var destinazione = new Ext.data.Store({
        //autoDestroy: true,
        storeid: 'destinazioneRec',
        id:'destinazioneRec',
        //idIndex: 0,
        fields: ['id','name','column1 ','column1 ']
});

I've a situation like this, two grid panel , two store and i've to drag a record and drop into the "destinazione" and is possibile to allow duplicate records into it.

I add the duplicate records in the second grid (Rec 0 - Rec 0) but after saving into the grid there is only one records.

How can i fix ? thanks

1

1 Answers

2
votes

By default id property is primary key and you can't have more then one record in the store with the same key. You can change primary that by specifying idProperty to something else, but it's not gonna solve your problem anyway.

If you have two stores and move records from one to another - then it's a good idea to either filter out already selected records from the original store and even remove them.