Categories | Question details Back To List | ||
Drag and Drop Question Hi, we are dragging from a treegrid to a treegrid. the first tree grid has several levels of folders and each folder has various leaves in. when they drag to a folder in the second treegrid we dont want it to add all the folders that are dragged but just the leaves into the folder. here is an example of what i mean: in the first grid we have the following folders and laves folder 1 folder 1a item 1 item 2 folder 1b item 3 item 4 in the second grid we have: folder a folder b if they drag folder folder 1 from the first tree into folder a in the second tree it appears as: folder a folder 1 folder 1a item 1 item 2 folder 1b item 3 item 4 folder b which is fine but we want it to take out all folders when it is dragged into the second grid and only place the leaves in there as follows: folder a item 1 item 2 item 3 item 4 folder b we realise that this is something specific to our project but was wondering if there was an easy way to do this thanks Answer posted by Stanislav on Nov 26, 2007 10:32 The most simple approach is to use onDrag event to catch data about moved elements, block d-n-d by returning false from event, and manually move necessary rows by moveRow command ( which can move row between grids as well ) Of course it also possible to achieve same effect with modification of existing code, but it will be a complex one. Answer posted by Richard White on Nov 30, 2007 05:05 Hi we have tried to do this manually except we are having a problem with the idfrom array that is being passed. if a folder gets dragged only the folder id is passed but not its contents ids. we need its contents ids so we can search through gthem to see what are folders and what are leaves. when a folder with contents is dragged how can we set it to pass over all the items that is trying to be dragged thanks also we noticed that mygrid.getRowsNum() only returns the number of tree items that are visible, the contents of a tree which have a closed folder and are therefore not visible are not counted, is this a bug? if not how do we get round it? if this isnt a bug we would suggest having to methods: mygrid.getVisibleRowsNum() and mygrid.getTotalRowsNum() thanks Answer posted by Richard White on Dec 04, 2007 18:30 Please can you tell us why you have not answered this question when we asked it nearly a week ago. In my question named response times you stated as long as i ask a question from 9-6 mon to fri we would get a reply. you are replying to others so this seems very strange. we have asked a few questions in this time and none of them have been answered?? Answer posted on Dec 05, 2007 01:42 >>when a folder with contents is dragged how can we set it to pass over all the items that is trying to be dragged It can be done with small code modification, but I think existing code already allow similar functionality, which can be done in next manner targetGrid.attachEvent("onDrag",function(sid, tid, sgrid, tgrid){ var ids=sid.split(","); //convert to array for (...){ var childs=sgrid.getSubItems(ids[i]); //get child items IDs childs=childs.split(","); //convert to array //here we have IDs of child items } }); Answer posted on Dec 05, 2007 01:46 >>also we noticed that mygrid.getRowsNum() only returns the number of
tree items that are visible, the contents of a tree which have a closed
folder This is expected behavior, existing functionality nested from plain grid, so may be not so usefull in case of treeGrid ( in both cases it returns count of visible|operable rows ) If you need functionality for counting all rows in TreeGrid you can use next workaround. var total=0; grid.forEachRow(function(){ total++; }); Answer posted on Dec 05, 2007 01:48 >>Please can you tell us why you have not answered this question when we asked it nearly a week ago Sorry for inconvenience, somehow we just missed your question. Answer posted by Richard White on Dec 05, 2007 05:04 Thanks very much, we really appreciate your answers richard |