How to swap items instead of adding into the same container?How do JavaScript closures work?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How to insert an item into an array at a specific index (JavaScript)?How do I include a JavaScript file in another JavaScript file?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?

What is the name of the technique when an element is repeated at different scales?

Sleepy tired vs physically tired

Is it acceptable that I plot a time-series figure with years increasing from right to left?

Motorcyle Chain needs to be cleaned every time you lube it?

What instances can be solved today by modern solvers (pure LP)?

Is it possible that Curiosity measured its own methane or failed doing the spectrometry?

Why did C++11 make std::string::data() add a null terminating character?

Term for a character that only exists to be talked to

Does the Milky Way orbit around anything?

Interview Question - Card betting

Speeding up thousands of string parses

Does Evolution Sage proliferate Blast Zone when played?

What's the difference between a type and a kind?

Why did the "Orks" never develop better firearms than Firelances and Handcannons?

What happens if the limit of 4 billion files was exceeded in an ext4 partition?

Should I cheat if the majority does it?

CPA filed late returns, stating I would get money; IRS says they were filed too late

List comprehensions in Mathematica?

Has there ever been a cold war other than between the U.S. and the U.S.S.R.?

Boss has banned cycling to work because he thinks it's unsafe

Is conquering your neighbors to fight a greater enemy a valid strategy?

Do intermediate subdomains need to exist?

How to iterate equal values with the standard library?

How frequently do Russian people still refer to others by their patronymic (отчество)?



How to swap items instead of adding into the same container?


How do JavaScript closures work?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How to insert an item into an array at a specific index (JavaScript)?How do I include a JavaScript file in another JavaScript file?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am using the react library dazzle https://github.com/Raathigesh/dazzle and the default add method allows it such that when one widget is dragged and dropped to another container the container expands to hold both widgets. Would it be possible to have it such that the widgets swap. ex. drag A to container B, widget B now moves to container A and widget A is now in container b. Any help would be great:



import React, Component from 'react';
import Dashboard, addWidget from 'react-dazzle';


import Header from './Header';
import EditBar from './EditBar';
import Container from './Container';
import AddWidgetDialog from './AddWidgetDialog';
import CustomFrame from './CustomFrame';


import BarChart from './widgets/BarChart';
import LineChart from './widgets/LineChart';
//import ApprovalList from './ApprovalList';
import DataTable from './tableWidget';

import 'bootstrap/dist/css/bootstrap.css';


import 'react-dazzle/lib/style/style.css';


import '../styles/custom.css';

class App extends Component
constructor(props)
super(props);
this.state =

widgets:
BarWidget:
type: BarChart,
title: 'Bar Graph Widget',
,
ApprovalWidget:
type: DataTable,
title: 'Order Approval',
,
LineWidget:
type: LineChart,
title: 'Trend Graph Widget',
,


,

layout:
rows: [
columns: [
className: 'col-md-12 col-sm-12 col-xs-12',
widgets: [key: 'LineWidget'],
],
,
columns: [
className: 'col-md-8 col-sm-8 col-xs-8',
widgets: [key: 'BarWidget'],
,
className: 'col-md-4 col-sm-4 col-xs-4',
widgets: [key: 'ApprovalWidget'],
],
],
,
editMode: false,
isModalOpen: false,
addWidgetOptions: null,
;



onRemove = (layout) =>
this.setState(
layout: layout,
);



onAdd = (layout, rowIndex, columnIndex) =>

this.setState(
isModalOpen: true,
addWidgetOptions:
layout,
rowIndex,
columnIndex,
,
);


onMove = (layout) =>
this.setState(
layout: layout,
);



onRequestClose = () =>
this.setState(
isModalOpen: false,
);


render()
return (
<Container>
<AddWidgetDialog widgets=this.state.widgets isModalOpen=this.state.isModalOpen onRequestClose=this.onRequestClose onWidgetSelect=this.handleWidgetSelection/>
<Header />
<EditBar onEdit=this.toggleEdit />
<Dashboard
frameComponent=CustomFrame
onRemove=this.onRemove
layout=this.state.layout
widgets=this.state.widgets
editable=this.state.editMode
onAdd=this.onAdd
onMove=this.onMove
addWidgetComponentText="Add New Widget"
/>

</Container>
);


toggleEdit = () =>
this.setState(
editMode: !this.state.editMode,
);
;

handleWidgetSelection = (widgetName) =>
const layout, rowIndex, columnIndex = this.state.addWidgetOptions;


this.setState(
layout: addWidget(layout, rowIndex, columnIndex, widgetName),
);

this.onRequestClose();



export default App;









share|improve this question



















  • 1





    Maintain a variable of the existing widget value. When you add a widget, call removeWidget(layout, rowIndex, columnIndex, widgetIndex); with the existing value and after that, add like you are already doing.

    – Shivam Gupta
    Mar 25 at 19:34











  • I was thinking the same thing but I am fairly new to react and I am not sure how to implement this as there is no pre-existing removeWidget() method.

    – Indusha Sembakutti
    Mar 25 at 19:59











  • You can ask the dazzle developer to expose the removeWidget method. They already use it internally in edit mode. They have an onRemove method, but I don't think it does what we want it to do here.

    – Shivam Gupta
    Mar 25 at 22:06

















0















I am using the react library dazzle https://github.com/Raathigesh/dazzle and the default add method allows it such that when one widget is dragged and dropped to another container the container expands to hold both widgets. Would it be possible to have it such that the widgets swap. ex. drag A to container B, widget B now moves to container A and widget A is now in container b. Any help would be great:



import React, Component from 'react';
import Dashboard, addWidget from 'react-dazzle';


import Header from './Header';
import EditBar from './EditBar';
import Container from './Container';
import AddWidgetDialog from './AddWidgetDialog';
import CustomFrame from './CustomFrame';


import BarChart from './widgets/BarChart';
import LineChart from './widgets/LineChart';
//import ApprovalList from './ApprovalList';
import DataTable from './tableWidget';

import 'bootstrap/dist/css/bootstrap.css';


import 'react-dazzle/lib/style/style.css';


import '../styles/custom.css';

class App extends Component
constructor(props)
super(props);
this.state =

widgets:
BarWidget:
type: BarChart,
title: 'Bar Graph Widget',
,
ApprovalWidget:
type: DataTable,
title: 'Order Approval',
,
LineWidget:
type: LineChart,
title: 'Trend Graph Widget',
,


,

layout:
rows: [
columns: [
className: 'col-md-12 col-sm-12 col-xs-12',
widgets: [key: 'LineWidget'],
],
,
columns: [
className: 'col-md-8 col-sm-8 col-xs-8',
widgets: [key: 'BarWidget'],
,
className: 'col-md-4 col-sm-4 col-xs-4',
widgets: [key: 'ApprovalWidget'],
],
],
,
editMode: false,
isModalOpen: false,
addWidgetOptions: null,
;



onRemove = (layout) =>
this.setState(
layout: layout,
);



onAdd = (layout, rowIndex, columnIndex) =>

this.setState(
isModalOpen: true,
addWidgetOptions:
layout,
rowIndex,
columnIndex,
,
);


onMove = (layout) =>
this.setState(
layout: layout,
);



onRequestClose = () =>
this.setState(
isModalOpen: false,
);


render()
return (
<Container>
<AddWidgetDialog widgets=this.state.widgets isModalOpen=this.state.isModalOpen onRequestClose=this.onRequestClose onWidgetSelect=this.handleWidgetSelection/>
<Header />
<EditBar onEdit=this.toggleEdit />
<Dashboard
frameComponent=CustomFrame
onRemove=this.onRemove
layout=this.state.layout
widgets=this.state.widgets
editable=this.state.editMode
onAdd=this.onAdd
onMove=this.onMove
addWidgetComponentText="Add New Widget"
/>

</Container>
);


toggleEdit = () =>
this.setState(
editMode: !this.state.editMode,
);
;

handleWidgetSelection = (widgetName) =>
const layout, rowIndex, columnIndex = this.state.addWidgetOptions;


this.setState(
layout: addWidget(layout, rowIndex, columnIndex, widgetName),
);

this.onRequestClose();



export default App;









share|improve this question



















  • 1





    Maintain a variable of the existing widget value. When you add a widget, call removeWidget(layout, rowIndex, columnIndex, widgetIndex); with the existing value and after that, add like you are already doing.

    – Shivam Gupta
    Mar 25 at 19:34











  • I was thinking the same thing but I am fairly new to react and I am not sure how to implement this as there is no pre-existing removeWidget() method.

    – Indusha Sembakutti
    Mar 25 at 19:59











  • You can ask the dazzle developer to expose the removeWidget method. They already use it internally in edit mode. They have an onRemove method, but I don't think it does what we want it to do here.

    – Shivam Gupta
    Mar 25 at 22:06













0












0








0








I am using the react library dazzle https://github.com/Raathigesh/dazzle and the default add method allows it such that when one widget is dragged and dropped to another container the container expands to hold both widgets. Would it be possible to have it such that the widgets swap. ex. drag A to container B, widget B now moves to container A and widget A is now in container b. Any help would be great:



import React, Component from 'react';
import Dashboard, addWidget from 'react-dazzle';


import Header from './Header';
import EditBar from './EditBar';
import Container from './Container';
import AddWidgetDialog from './AddWidgetDialog';
import CustomFrame from './CustomFrame';


import BarChart from './widgets/BarChart';
import LineChart from './widgets/LineChart';
//import ApprovalList from './ApprovalList';
import DataTable from './tableWidget';

import 'bootstrap/dist/css/bootstrap.css';


import 'react-dazzle/lib/style/style.css';


import '../styles/custom.css';

class App extends Component
constructor(props)
super(props);
this.state =

widgets:
BarWidget:
type: BarChart,
title: 'Bar Graph Widget',
,
ApprovalWidget:
type: DataTable,
title: 'Order Approval',
,
LineWidget:
type: LineChart,
title: 'Trend Graph Widget',
,


,

layout:
rows: [
columns: [
className: 'col-md-12 col-sm-12 col-xs-12',
widgets: [key: 'LineWidget'],
],
,
columns: [
className: 'col-md-8 col-sm-8 col-xs-8',
widgets: [key: 'BarWidget'],
,
className: 'col-md-4 col-sm-4 col-xs-4',
widgets: [key: 'ApprovalWidget'],
],
],
,
editMode: false,
isModalOpen: false,
addWidgetOptions: null,
;



onRemove = (layout) =>
this.setState(
layout: layout,
);



onAdd = (layout, rowIndex, columnIndex) =>

this.setState(
isModalOpen: true,
addWidgetOptions:
layout,
rowIndex,
columnIndex,
,
);


onMove = (layout) =>
this.setState(
layout: layout,
);



onRequestClose = () =>
this.setState(
isModalOpen: false,
);


render()
return (
<Container>
<AddWidgetDialog widgets=this.state.widgets isModalOpen=this.state.isModalOpen onRequestClose=this.onRequestClose onWidgetSelect=this.handleWidgetSelection/>
<Header />
<EditBar onEdit=this.toggleEdit />
<Dashboard
frameComponent=CustomFrame
onRemove=this.onRemove
layout=this.state.layout
widgets=this.state.widgets
editable=this.state.editMode
onAdd=this.onAdd
onMove=this.onMove
addWidgetComponentText="Add New Widget"
/>

</Container>
);


toggleEdit = () =>
this.setState(
editMode: !this.state.editMode,
);
;

handleWidgetSelection = (widgetName) =>
const layout, rowIndex, columnIndex = this.state.addWidgetOptions;


this.setState(
layout: addWidget(layout, rowIndex, columnIndex, widgetName),
);

this.onRequestClose();



export default App;









share|improve this question
















I am using the react library dazzle https://github.com/Raathigesh/dazzle and the default add method allows it such that when one widget is dragged and dropped to another container the container expands to hold both widgets. Would it be possible to have it such that the widgets swap. ex. drag A to container B, widget B now moves to container A and widget A is now in container b. Any help would be great:



import React, Component from 'react';
import Dashboard, addWidget from 'react-dazzle';


import Header from './Header';
import EditBar from './EditBar';
import Container from './Container';
import AddWidgetDialog from './AddWidgetDialog';
import CustomFrame from './CustomFrame';


import BarChart from './widgets/BarChart';
import LineChart from './widgets/LineChart';
//import ApprovalList from './ApprovalList';
import DataTable from './tableWidget';

import 'bootstrap/dist/css/bootstrap.css';


import 'react-dazzle/lib/style/style.css';


import '../styles/custom.css';

class App extends Component
constructor(props)
super(props);
this.state =

widgets:
BarWidget:
type: BarChart,
title: 'Bar Graph Widget',
,
ApprovalWidget:
type: DataTable,
title: 'Order Approval',
,
LineWidget:
type: LineChart,
title: 'Trend Graph Widget',
,


,

layout:
rows: [
columns: [
className: 'col-md-12 col-sm-12 col-xs-12',
widgets: [key: 'LineWidget'],
],
,
columns: [
className: 'col-md-8 col-sm-8 col-xs-8',
widgets: [key: 'BarWidget'],
,
className: 'col-md-4 col-sm-4 col-xs-4',
widgets: [key: 'ApprovalWidget'],
],
],
,
editMode: false,
isModalOpen: false,
addWidgetOptions: null,
;



onRemove = (layout) =>
this.setState(
layout: layout,
);



onAdd = (layout, rowIndex, columnIndex) =>

this.setState(
isModalOpen: true,
addWidgetOptions:
layout,
rowIndex,
columnIndex,
,
);


onMove = (layout) =>
this.setState(
layout: layout,
);



onRequestClose = () =>
this.setState(
isModalOpen: false,
);


render()
return (
<Container>
<AddWidgetDialog widgets=this.state.widgets isModalOpen=this.state.isModalOpen onRequestClose=this.onRequestClose onWidgetSelect=this.handleWidgetSelection/>
<Header />
<EditBar onEdit=this.toggleEdit />
<Dashboard
frameComponent=CustomFrame
onRemove=this.onRemove
layout=this.state.layout
widgets=this.state.widgets
editable=this.state.editMode
onAdd=this.onAdd
onMove=this.onMove
addWidgetComponentText="Add New Widget"
/>

</Container>
);


toggleEdit = () =>
this.setState(
editMode: !this.state.editMode,
);
;

handleWidgetSelection = (widgetName) =>
const layout, rowIndex, columnIndex = this.state.addWidgetOptions;


this.setState(
layout: addWidget(layout, rowIndex, columnIndex, widgetName),
);

this.onRequestClose();



export default App;






javascript reactjs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 20:20









Mis94

1,3641 gold badge11 silver badges27 bronze badges




1,3641 gold badge11 silver badges27 bronze badges










asked Mar 25 at 19:11









Indusha SembakuttiIndusha Sembakutti

438 bronze badges




438 bronze badges







  • 1





    Maintain a variable of the existing widget value. When you add a widget, call removeWidget(layout, rowIndex, columnIndex, widgetIndex); with the existing value and after that, add like you are already doing.

    – Shivam Gupta
    Mar 25 at 19:34











  • I was thinking the same thing but I am fairly new to react and I am not sure how to implement this as there is no pre-existing removeWidget() method.

    – Indusha Sembakutti
    Mar 25 at 19:59











  • You can ask the dazzle developer to expose the removeWidget method. They already use it internally in edit mode. They have an onRemove method, but I don't think it does what we want it to do here.

    – Shivam Gupta
    Mar 25 at 22:06












  • 1





    Maintain a variable of the existing widget value. When you add a widget, call removeWidget(layout, rowIndex, columnIndex, widgetIndex); with the existing value and after that, add like you are already doing.

    – Shivam Gupta
    Mar 25 at 19:34











  • I was thinking the same thing but I am fairly new to react and I am not sure how to implement this as there is no pre-existing removeWidget() method.

    – Indusha Sembakutti
    Mar 25 at 19:59











  • You can ask the dazzle developer to expose the removeWidget method. They already use it internally in edit mode. They have an onRemove method, but I don't think it does what we want it to do here.

    – Shivam Gupta
    Mar 25 at 22:06







1




1





Maintain a variable of the existing widget value. When you add a widget, call removeWidget(layout, rowIndex, columnIndex, widgetIndex); with the existing value and after that, add like you are already doing.

– Shivam Gupta
Mar 25 at 19:34





Maintain a variable of the existing widget value. When you add a widget, call removeWidget(layout, rowIndex, columnIndex, widgetIndex); with the existing value and after that, add like you are already doing.

– Shivam Gupta
Mar 25 at 19:34













I was thinking the same thing but I am fairly new to react and I am not sure how to implement this as there is no pre-existing removeWidget() method.

– Indusha Sembakutti
Mar 25 at 19:59





I was thinking the same thing but I am fairly new to react and I am not sure how to implement this as there is no pre-existing removeWidget() method.

– Indusha Sembakutti
Mar 25 at 19:59













You can ask the dazzle developer to expose the removeWidget method. They already use it internally in edit mode. They have an onRemove method, but I don't think it does what we want it to do here.

– Shivam Gupta
Mar 25 at 22:06





You can ask the dazzle developer to expose the removeWidget method. They already use it internally in edit mode. They have an onRemove method, but I don't think it does what we want it to do here.

– Shivam Gupta
Mar 25 at 22:06












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55344914%2fhow-to-swap-items-instead-of-adding-into-the-same-container%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55344914%2fhow-to-swap-items-instead-of-adding-into-the-same-container%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현