jQuery UI Widgets Forums Grid Grid Drag and Drop Question

Tagged: 

This topic contains 2 replies, has 1 voice, and was last updated by  DavidSimmons 11 years, 6 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Grid Drag and Drop Question #16100

    DavidSimmons
    Participant

    I am trying to understand the dragStart or dragEnd event to see if I can drag from the a grid and drop it into some other droppable element. (FullCalendar) One of the requirements are that the Text or Cell Text that is dropped is a eventObject defined as title: $.trim($(this).text()).

    My examples are http://www.digitalconceptdesigns.com/DND/DND.php

    rendered: function(type)
    {
    ….
    gridCells.jqxDragDrop({
    ……

    //**************************
    //This would be the $(‘#calendar’)
    dropTarget: $(‘#grid2’), revert: true
    });
    …….
    // initialize the dragged object.
    gridCells.on(‘dragStart’, function (event) {
    var value = $(this).text();
    var cell = $(“#grid1”).jqxGrid(‘getcellatposition’, event.args.pageX, event.args.pageY);

    //**************************
    //Need to convert the cell text into a eventObject before sending like this
    var eventObject = {
    title: $.trim($(this).text()) // use the element’s text as the event title
    };

    $(this).data(‘eventObject’, eventObject);
    //**************************
    //I am not sure what this part is doing, can you help me understand?
    $(this).jqxDragDrop(‘data’, {
    value: value
    });
    });

    // set the new cell value when the dragged cell is dropped over the second Grid.
    gridCells.on(‘dragEnd’, function (event) {
    //**************************
    //If my calendar handles the Drop event, is this still needed? I am not sure….
    var value = $(this).text();
    var cell = $(“#grid2”).jqxGrid(‘getcellatposition’, event.args.pageX, event.args.pageY);
    if (cell != null) {
    $(“#grid2”).jqxGrid(‘setcellvalue’, cell.row, cell.column, value);
    }
    });
    },

    Grid Drag and Drop Question #17106

    DavidSimmons
    Participant

    Using your example under grids Drag & Drop can you help under stand how I can only allow one column to be dragged from grid1 and only one column except the drop in grid2?

    I would appreciate any help…

    This example shows how to setup a one way drag and drop from a Grid to another Grid.

    $(document).ready(function () {
    var theme = getDemoTheme();
    var source =
    {
    localdata: generatedata(100),
    datafields:
    [
    { name: ‘firstname’, type: ‘string’ },
    { name: ‘lastname’, type: ‘string’ },
    { name: ‘productname’, type: ‘string’ }
    ],
    datatype: “array”
    };
    var dataAdapter = new $.jqx.dataAdapter(source);
    // create data grids.
    $(“#grid1”).jqxGrid(
    {
    width: 450,
    source: dataAdapter,
    pageable: true,
    autoheight: true,
    sortable: true,
    rendered: function(type)
    {
    // select all grid cells.
    var gridCells = $(‘#grid1’).find(‘.jqx-grid-cell’);
    // initialize the jqxDragDrop plug-in. Set its drop target to the second Grid.
    gridCells.jqxDragDrop({
    appendTo: ‘body’, theme: theme, dragZIndex: 99999,
    dropAction: ‘none’,
    initFeedback: function (feedback) {
    feedback.height(25);
    },
    dropTarget: $(‘#grid2’), revert: true
    });
    gridCells.off(‘dragEnd’);
    gridCells.off(‘dragEnd’);
    gridCells.off(‘dropTargetEnter’);
    gridCells.off(‘dropTargetLeave’);
    // disable revert when the dragged cell is over the second Grid.
    gridCells.on(‘dropTargetEnter’, function () {
    gridCells.jqxDragDrop({ revert: false });
    });
    // enable revert when the dragged cell is outside the second Grid.
    gridCells.on(‘dropTargetLeave’, function () {
    gridCells.jqxDragDrop({ revert: true });
    });
    // initialize the dragged object.
    gridCells.on(‘dragStart’, function (event) {
    var value = $(this).text();
    var cell = $(“#grid1”).jqxGrid(‘getcellatposition’, event.args.pageX, event.args.pageY);
    $(this).jqxDragDrop(‘data’, {
    value: value
    });
    });
    // set the new cell value when the dragged cell is dropped over the second Grid.
    gridCells.on(‘dragEnd’, function (event) {
    var value = $(this).text();
    var cell = $(“#grid2”).jqxGrid(‘getcellatposition’, event.args.pageX, event.args.pageY);
    if (cell != null) {
    $(“#grid2”).jqxGrid(‘setcellvalue’, cell.row, cell.column, value);
    }
    });
    },
    theme: theme,
    selectionmode: ‘singlecell’,
    columns: [
    { text: ‘First Name’, dataField: ‘firstname’, width: 125 },
    { text: ‘Last Name’, dataField: ‘lastname’, width: 125 },
    { text: ‘Product’, dataField: ‘productname’, width: 200 }
    ]
    });
    $(“#grid2”).jqxGrid(
    {
    width: 450,
    theme: theme,
    selectionmode: ‘singlecell’,
    autoheight: true,
    source: { totalrecords: 10, unboundmode: true, datafields:
    [
    { name: ‘firstname’ },
    { name: ‘lastname’ },
    { name: ‘productname’ }
    ]
    },
    columns: [
    { text: ‘First Name’, dataField: ‘firstname’, width: 125 },
    { text: ‘Last Name’, dataField: ‘lastname’, width: 125 },
    { text: ‘Product’, dataField: ‘productname’, width: 200 }
    ]

    });
    });

    Grid Drag and Drop Question #17108

    DavidSimmons
    Participant

    Here is my example. I am trying to find a way to only allow certain columns to be draggable and certain columns to be droppable.

    I would appreciate any help…

    http://www.digitalconceptdesigns.com/DND/DND.php

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.