Hi,
I want to reset an attribute for a dropped row…is this possible?
Here is the situation:
I get the XML to fill the grid…one of the cells of each row has the attribute “status”.
I want to change that cell value when the row is dropped to another parent (using drag&drop).
I have the method HangleDrop defined in setDropHandler…but not sure how to get the “new” index of the dropped row.
FYI: i am using mercy drag.
Hope you can help me.
Thanks in advance.
Fernando
In case of mercy-drag - new row will have unique ID ( generated from timestamp)
Third parameter of onDrop event handler will be a new ID.
grid.attachEvent(“onDrop”,function(sid,tid,nid){
//sid - original row id
//nid - id of new row
// index = grid.getRowIndex(nid);
});
Correct. But seems like grid does not find the new row. If i do…
function HangleDrop(id_source, id_target, id_dropped, grid_source, grid_target){
alert("drop id " + id_dropped);
alert("drop object " + mygrid.getRowIndex(id_dropped));
}
In the first message, i get the new ID. But in the second i get “-1” as if it were not found.
Any idea why this could be occuring?
Thanks.
Fernando
Are you using grid or treeGrid ?
In second case it possible to drop element as child of closed branch - is such case it will not have index, while branch closed
I am using TreeGrid, from last version 1.5, we just purchased.
So, does it mean there is no solution for our problem? Do you know of any workaround we can use for performing this action?
Thanks.
Fernando
If you drop item in closed branch it really has not index ( because indexes are order of visible items )
Why do you need an index in first place ? Nearly all in-grid operation can be done with rowID, which you already have.
Let’s say we have item X only in folder A.
By using “mercy” drag, i am moving it to folder B (so, it’s COPY+PASTE). And i want to change an attribute for item X in folder B but leave the attribute as it is in folder A.
Can this be done with this product?
Thanks.
Fernando
>>Can this be done with this product?
sure, by using new item ID you can change any related attribute
function HangleDrop(id_source, id_target, id_dropped, grid_source, grid_target){
this.cells(id_dropped,0).setValue(“new one”); //change value in new row
this.setRowColor(id_dropped,“red”) // change row color
this.setUserData(id_dropped,“some”,“value”); //set row userdata
}
In all cases , when you using id_dropped - you updating only new row ( row B), the original ( row A ) preserved as is.
It worked perfectly.
Thanks!
Fernando.