user3045654
user3045654

Reputation: 1734

Do not drop the same records to grid

Hello i am have grid "Book" (id, name, price) and other grid "Sale" (id, name, price). I am insert records from "Book" to "Sale" with DragandDrop. But I need if user drop record to grid "Sale" and grid "Sale" already have same record (with same ID) - not drop this record. What do I need?

Upvotes: 0

Views: 342

Answers (2)

Surya Prakash Tumma
Surya Prakash Tumma

Reputation: 2203

use beforeadd listener and find out the old duplicate record and delete it!!

listeners:{
    beforeadd:function(store, records, index, eOpts) {        
        for (var i in records) {
            var idx = store.findExact('id', records[i].get('id'));
            if ( /*compare idx with new record id */) {
                store.remove(records[i]);
            }
        }
    }
}

Upvotes: 1

Hayk Mantashyan
Hayk Mantashyan

Reputation: 328

Just rename 'id' column and it will work.

Upvotes: 0

Related Questions