Results 1 to 6 of 6

Thread: Drag and drop using xtemplates in a grid

  1. #1
    Sencha Premium Member
    Join Date
    Mar 2012
    Location
    Scotland
    Posts
    111
    Answers
    7

    Default Answered: Drag and drop using xtemplates in a grid

    I've created a grid and it has drag and drop functionality which worked fine.
    that was until I changed the column to use xtype: 'templatecolumn'

    Now if I try to drag and drop it will only work if I drag the row by the area that doesn't have text.

    https://fiddle.sencha.com/#fiddle/5r5

    See the above fiddle which is a slightly modified code example taken from the docs on the ptype - gridviewdragdrop.

    So is this expected behaviour and is there a way to get around it? (using Ext JS 4.2.1)

    Thanks

  2. I believe this is the underlying cause of your problem:

    http://docs.sencha.com/extjs/4.2.1/#...lidHandleTypes

    It's not entirely clear why you would want a link to be draggable in this way.

  3. #2
    Sencha Premium Member
    Join Date
    Mar 2012
    Location
    Scotland
    Posts
    111
    Answers
    7

    Default

    While testing - if the XTemplate isn't a link the it works as expected.
    So - '<tpl>{name}</tpl>' would be OK
    But - '<tpl><a>{name}</a></tpl>' is NOT OK.

  4. #3
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    I believe this is the underlying cause of your problem:

    http://docs.sencha.com/extjs/4.2.1/#...lidHandleTypes

    It's not entirely clear why you would want a link to be draggable in this way.

  5. #4
    Sencha Premium Member
    Join Date
    Mar 2012
    Location
    Scotland
    Posts
    111
    Answers
    7

    Default

    Thanks - well at least that (sort of) explains why you can't drag an XTemplate with an <a> in it although it doesn't really give a reason as to why you can't.

    While dragging a link may not be common, in the example its a very much cut down version of what's happening. In reality there is a grid/column and in that grid the rows are XTemplates which contain information and a link. Each row can be dragged elsewhere on the page to initiate another action. (not my choice but a requirement).

    It would be good if the docs actually explained why you can't drag an <a>. Why can't it be treated like other tags and be draggable?

  6. #5
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    Just set:

    Code:
    grid.getView().getPlugin('dd').dragZone.invalidHandleTypes = {};
    where 'dd' is the pluginId.

    By the way, those attributeless <tpl> tags are meaningless.

  7. #6
    Sencha Premium Member
    Join Date
    Mar 2012
    Location
    Scotland
    Posts
    111
    Answers
    7

    Default

    Thanks, thats brilliant.
    Yes, I had copied/pasted from a much more complicated tpl where there was conditions and if's and I didn't think of cutting them out.
    Good to know.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •