I have a RecordDropHandler and I can see the DropRecords but I would like to remove some of the records been dropped if they do not meet a set of criteria.
Not sure how to do this since the event passed into this handler does not allow the code to setDropRecords(<new set of records>).
Sorry but the RecordDropHandler.onRecordDrop does not allow you to return false. Also I want to add these records at exactly a specific location index in the ListGrid.
Yes, see the drag and drop samples, it’s the default behavior. However note that if you’re using a DataSource with fetchData, since the dataset may be partially loaded so it’s not safe to insert at a specific position or row numbering will become confused, so by default, nothing happens.
Hi Sorry again, I went all of the SmartGWT examples on Drag and Drop and none of them have a insert at operation. Please just tell me the API call because I do not see it on ListGrid. Do I have to do something weird like create a display_order field and sort by this…(God say I don’t).
I understand that the grid can handle the adding of records but I want to be able to insert these dragged records at a specific location and the ListGrid.addData() will place them at the end and then sort by whatever field is sortable at that time. That is great but my ListGrid is not sortable on purpose because I want control where and what the user drops. If only some of the records are valid then I want them inserted under the location index where they were dropped.
So far what you are saying is that there is not an API and I have to use a custom displayOrder field to place them in a specific order then sort by this displayOrder field. The ListGrid does everything I need except the insert record at a specific index functionality.
If your using a simple Array as your dataset (you call setData()), drag and drop will insert the records at the drop position automatically without adding any code at all.
If for some reason you need to do this manually (again, collision detection is built in, so that’s not a reason to do it manually), the RecordDrop handler gives you the index and records to add: call getRecords(), insert the new records at the index, call setData() with new data.
Thanks but can you just give me the 2 lines of code to do this part “insert the new records at the index, call setData() with new data” because I do not see the API in ListGrid. What is the insert at API call and the setData() only takes records and not an index?
I have the lines of code to get the records and the index position to insert at but I do not have the ListGrid API call to perform this. I just need the few lines of Java code to do this.