jQWidgets Forums

jQuery UI Widgets Forums Plugins Validator, Drag & Drop, Sortable Drag and Drop – scope of access in dragdrop('data')

This topic contains 2 replies, has 2 voices, and was last updated by  alastairwalker 9 years, 6 months ago.

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

  • alastairwalker
    Participant

    I would like some clarification of the scope of the jqxdragdrop(‘data’) method.

    In the script fragment below, I need to make accessible row data on drag start, to the drag end script – so that I can update a mysql table – which is managing a nested index table.

    My problem is as follows: When I try to access the result of ‘jQuery(this).jqxDragDrop(‘data’, {sourceRowData});’ (as in the in the drag start script) object in the drag end script, (i.e. var sourceRowData = jQuery(this).jqxDragDrop(‘data’);) the result is ‘undefined’.

    Do I misunderstand the intent and purpose of the dragdrop (‘data) facility?

    Can it not be used to access data (captured in the dragstart) in the dragend script. and make the results accessible in the drag end script?

    Any advice here will be really appreciated!

    Alastair

    Script fragment is as follows:

    gridCells.on('dragStart', function (event) 
    {
        var position = jQuery.jqx.position(event.args);
        var cell = jQuery(this).jqxGrid('getcellatposition', position.left, position.top);
      	sourceRowData = jQuery(this).jqxGrid('getrowdata',cell.row);
      	
        jQuery(this).jqxDragDrop('data', {sourceRowData});   	                        
    });
    
    gridCells.on('dragEnd', function (event) 
    {
    	var sourceRowData = jQuery(this).jqxDragDrop('data');
    });

    Hristo
    Participant

    Hello alastairwalker,

    You have one missing ‘var sourceRowData’
    Could you like to try with this:

    
    

    gridCells.on(‘dragStart’, function (event) {
    var value = $(this).text();
    var position = $.jqx.position(event.args);
    var cell = $(“#grid1”).jqxGrid(‘getcellatposition’, position.left, position.top);
    var sourceRowData = $(“#grid1”).jqxGrid(‘getrowdata’, cell.row);

    $(this).jqxDragDrop(‘data’, {
    value: value,
    sourceRowData: sourceRowData
    });
    });

    gridCells.on(‘dragEnd’, function (event) {
    var sourceRowDataTest = $(this).jqxDragDrop(‘data’);
    console.log(sourceRowDataTest);
    });

    
    

    If would like to provide us one example in (https://www.jseditor.io/ or http://fiddle.jshell.net/) for better analyze.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com


    alastairwalker
    Participant

    Many thanks – that corrected it!

    Alastair

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

You must be logged in to reply to this topic.