I have two grids on a page. One is populated with data from an external XML source, and one is completely empty. I have enabled drag and drop on both grids, but I can not drag anything to the empty grid. Here is my code:
var mygrid = new dhtmlXGridObject('mygrid');
mygrid.setIconsPath('script/codebase/imgs/');
mygrid.setHeader("col 1");
mygrid.setColTypes("ro");
mygrid.setColSorting('str');
mygrid.enableResizing('false');
mygrid.enableDragAndDrop(true);
mygrid.enableMercyDrag(false);
mygrid.enableMultiselect(true);
mygrid.init();
mygrid.detachHeader(0);
mygrid.loadXML("test.xml");//load data
var mygrid1 = new dhtmlXGridObject('mygrid1');
mygrid1.setIconsPath('script/codebase/imgs/');
mygrid1.setHeader("col 1, col 2");
mygrid1.setInitWidths("*,50");
mygrid1.setColVAlign('left,right');
mygrid1.setColSorting('str,int');
mygrid1.setColTypes("ro,ro");
mygrid1.enableResizing('false');
mygrid1.enableDragAndDrop(true);
mygrid1.enableMercyDrag(false);
mygrid1.enableMultiselect(true);
mygrid1.init();
Also, In the DHTMLX Designer, when drag and drop is enabled, it doesn’t appear to work when I drop on any of the white space below where the grid rows stop. Seems to work fine when I drag on top of an existing row.
Ok, So I actually do have an issue after all, and this time its not a spelling mistake. See the following code:
grid2.attachEvent("onDrop", function(sId,tId,dId,sObj,tObj,sCol,tCol){
//grid2.cells(tId,1).setValue("test");
alert(tId)
});
When I DnD from grid1 to grid2 I would like use the above handler to set some of the columns on grid2 that do not get copped from grid1. But right now I am getting an error, and with above test code, it pops “unknown” in the alert window. I believe this is happening when I drag from grid1 and drop into the empty space on grid2. When I drop onto an existing row in grid2, my test code fires and the value of tId is the ID of the row I dropped on. How can I make this work if the grid is partially full/empty? Do I need to do this type of thing under another event?
This is an expectable behavior.
“tId” attribute has the id of the row after which the dropped row should be placed. If you drop the row into an empty grid that attribute cannot be defined.
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan