Search code examples
reactjsreact-grid-layout

draggableCancel on react-grid-layout


I am using react grid layout with amcharts3-react everything is just fine, I can move elements around but, this time I can't use amcarts Zoom handles... They are draggable as well.I tried to use grid layout's cancelDraggable feature but nothing happened. even it didn't prevent the area that I specify for nonedragging. What could be the possible solution?

enter image description here

                <GridLayout>
                  <div key="d" data-grid={{x: 4, y: 0, w: 4, h: 2, draggableHandle: '.dragHandle', draggableCancel:'.noneDraggable'}}>
                    <span className="dragHandle">[DRAG HERE]</span>
                    <div className="noneDraggable">
                      <Chart />
                    </div>
                  </div>

                  <div key="c" data-grid={{x: 0, y: 0, w: 4, h: 2}}>
                    <Chart />
                  </div>

                </GridLayout>


Solution

  • I solved by associating the property to the dashboard itself, not the items, like so:

    <ResponsiveReactGridLayout 
      rowHeight={75}
      layouts={this.props.dashboard.record.layout} 
      onBreakpointChange={this.onBreakpointChange.bind(this)}
      onDragStop={this.onDragStop.bind(this)}
      draggableCancel='.dashboard-item-content' 
      draggableHandle='.dashboard-item-header'
      onResizeStop={this.onResizeStop.bind(this)}>
        {this.generateDOM()}
    </ResponsiveReactGridLayout>
    

    Try to associate the 2 properties to your GridLayout jsx node.