ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Drag & drop From one grid to another
Title:
B
I
{code}
?
I see your sample https://demo.aspnetawesome.com/DragAndDropDemo#From-one-grid-to-another All run ok, but the function to get all ids selected seem not run good .. es. 211,209,211,211 <- there 4 ids but I have dragged only 2 rows ! $(function () { $('#MealsGrid1, #MealsGrid2').on('awedrop', function (e, data) { //var row = $(e.target); //$('#log').prepend(row.data('model').Name + ' moved from ' + data.from.closest('.awe-grid').attr('id') + // ' to ' + row.closest('.awe-grid').attr('id') + '<br/>'); selected = $('#MealsGrid2').find('.awe-row').map(function (i, el) { return $(el).data('k'); }).get(); $('#log').text(selected.join(",")); }); });
Save Changes
Cancel
Meccanica Rossi
asked at 08 Jun 2018
Answers
B
I
{code}
?
`$('#MealsGrid2').find('.awe-row')` will give you all the rows in the grid ( everything that has `awe-row` class ) there are many ways to identify which rows have been dragged: you could compare with the data from the server; add a class or html attribute to the dropped row on `awedrop` $('#MealsGrid2').on('awedrop', function (e, data){ var droppedRow = e.target; var dropOnSameGrid = data.from.is($(droppedRow).closest('.awe-content')); if(!dropOnSameGrid) $(droppedRow).addClass('dropped'); // and after use `.find('.dropped')` }); or maybe just add the row to a js array on drop, depends on your scenario $('#MealsGrid2').on('awedrop', function (e, data){ var droppedRow = e.target; var dropOnSameGrid = data.from.is($(droppedRow).closest('.awe-content')); if(!dropOnSameGrid) mycollection.push(droppedRow); // you might need to remove the row from mycollection if it will be dragged on a different grid (probably on the original) });
Save Changes
Cancel
Omu
answered at 08 Jun 2018
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK