jQWidgets Forums
jQuery UI Widgets › Forums › Grid › drag and drop decided row by row
This topic contains 2 replies, has 2 voices, and was last updated by Klaus H 12 years ago.
-
Author
-
Hello,
I am looking for a way to be able to drag and drop only certain rows from my grid to another grid. There is a lookup field by which the data is sorted and only data with the third value is allowed to be dragged.
My first try to use a cellrenderer callback function that returns ‘dragable’ if the value is 3. I then altered your drag and drop example in one line:
var gridCells = $('#jqxgrid').find('.jqx-grid-cell.dragable');
That generally works and I am only able to drag the rows I want to the other grid. The other rows show the normal cursor. The problem starts when there is so much data, that I have to scroll in the grid to get to the data. Then, the dragging does not work anymore (cells that were not visible before were rendered new?) – I have tested this in 3 browsers. The css classes attached to the cell are correct.
My second try was to check the value of the attribute in the dragEnd event before adding the row in the target grid and deleting it in the source grid. That method works, but it allows the column to be dragged in the first place and if possible, I’d like to avoid that.
So, is there any way I might get my first attempt to work correctly or is there another solution I have not thought of?
Kind Regards
KlausHello Klaus,
Similarly to your second approach, you may check for the value on the dragStart event.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hello Dimitar,
I have tried that:
var cell = $("#jqxgrid").jqxGrid('getcellatposition', event.args.pageX, event.args.pageY);rowindex = cell.row;var data = $('#jqxgrid').jqxGrid('getrowdata', rowindex);if(data.attribute == 3){ $(this).jqxDragDrop('data', $('#jqxgrid').jqxGrid('getrowdata', rowindex));}
The behaviour stays the same, the cursor obviously has the drag and drop sign and I can still move the cell for some reason, but not remove it from the source grid and add to the target grid as it is supposed to be.
I would still prefer a solution like my first approach, is there any event or behaviour that I can attach the same code I used in rendered for when rows are rendered due to scrolling or something like that?
Kind Regards
Klaus -
AuthorPosts
You must be logged in to reply to this topic.