Categories | Question details Back To List | ||
dhtmlXgrid - Setting attributed to a "dropped" row 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 Answer posted by Support on Feb 13, 2008 03:19 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); }); Answer posted by Fernando on Feb 13, 2008 05:49 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){ } 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 Answer posted by Support on Feb 14, 2008 04:23 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 Answer posted on Feb 14, 2008 04:28 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 Answer posted by Support on Feb 14, 2008 09:51 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. Answer posted by Fernando on Feb 14, 2008 09:59 Let's say we have item X only in folder A. Can this be done with this product? Thanks. Fernando Answer posted by Support on Feb 15, 2008 05:52 >>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. Answer posted by Fernando on Feb 15, 2008 07:14 It worked perfectly. Thanks! Fernando. |