0
votes

We are providing an ability to the user to change the order/position of a grid record. For this we are using drag and drop. But after drag and drop the record doesn't appear dirty.

Thus, is there any function which can be used to forcefully mark as well as unmark a grid record as dirty? That is, forcing it to display/hide the red mark in corner.

I found a function - setDirty() on the record. But this doesn't serve the purpose.

1
Does your model include the index property? I believe it is the property that changes when you reorder things, and if defined in the model the model record should become dirty upon drag-drop (works for trees anyway).Izhaki
I think you should set a listener to your DragDrop plugin on drop Event and there you can process all the order-related changes (send new position to server and so on).s.webbandit
@Izhaki: There is an index in the store, but index in model I have not heard of. Could you please elaborate a bit more at what you are mentioning?netemp
@webbandit: Thanks for the post. We are able to take care of the server side updation, but the issue is that how should a user gets to know that he has changed the order of some record? If that record gets marked dirty then its easier for the user to identify that the record order has been changed. Any thoughts on this?netemp
Just add a field {name: 'index', type: 'int'} to your model - it might do the trick. By defining it, ExtJS will monitor changes to it and will mark any record as dirty when you re-order your records (again, this is how trees work, which I assume is the same for grids).Izhaki

1 Answers

1
votes

I've done a sequencing drag and drop grid before. I had a sequence column on the database and so simply included it in my model definition.

Then in the gridview's drop event handler, I called record.set('sequence', newSequence) on all effected records whenever a drop was performed. (I say "all effected records" because whenever you change the sequence of one record it doesn't only effect the sequence of that one record e.g.: if you move a record from the very bottom of the grid to the very top all of record sequence numbers after the dropped record will be increased by one, they will all be dirty and need to be updated on the database).

Using record.set will then show that the record's sequence column is dirty with a flag.

You said that you have the server side updating ok so I am assuming that you are performing this resequencing logic on the server side, you would have to move it back onto the JS, I don't know if you want to do that.