Click here to Skip to main content
15,886,714 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please help me, i have a project dashboard widgets using drag and drop. I have left(widgets lists) and right(widgets area). widgets on left are draggable and droppable into widgets area.

When the widgets example:staff list(just a title) is dragged and dropped on the widgets area it shows the list of name in datagrid. I manage to do that.

However, my problem is on the charts, it doesn't show anything but it cloned the div that the chart is using. Please help me guys, any information will be appreciated. btw im using jqx for chart

Here's my code to give you information:

HTML
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Eto Na</title>
  <script type="text/javascript" src="jquery-1.11.1.min.js"></script>

  <script src="jquery.gridster.js" type="text/javascript" charset="utf-8"></script>
  <script src="jquery-ui.js" type="text/javascript" charset="utf-8"></script>
  <link rel="stylesheet" type="text/css" href="jquery.gridster.css">
  <script type="text/javascript" src="dragNdrop.js"></script>   
	<!--Datable Tables-->
    <script type="text/javascript" language="javascript" src="dtjs/data-tables.js"></script>
	<script type="text/javascript" language="javascript" src="dtjs/jquery.dataTables.js"></script>
 	<link rel="stylesheet" type="text/css" href="dtcss/jquery.dataTables.css">
	<link rel="stylesheet" type="text/css" href="dtcss/demo.css">
     <script type="text/javascript" src="jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="jqwidgets/jqxdraw.js"></script>
    <script type="text/javascript" src="jqwidgets/jqxchart.core.js"></script>
    <script type="text/javascript" src="jqwidgets/jqxdata.js"></script>   
    
    <script type="text/javascript">
        $(document).ready(function () {

            // prepare chart data
            var sampleData = [
                { Country: 'China', Population: 1347350000, Percent: 19.18},
                { Country: 'India', Population: 1210193422, Percent: 17.22},
                { Country: 'USA', Population: 313912000, Percent: 4.47},
                { Country: 'Indonesia', Population: 237641326, Percent: 3.38},
                { Country: 'Brazil', Population: 192376496, Percent: 2.74}];

            // prepare jqxChart settings
            var settings = {
                title: "Top 5 most populated countries",
                description: "Statistics for 2011",
                showLegend: true,
                enableAnimations: true,
                padding: { left: 20, top: 5, right: 20, bottom: 5 },
                titlePadding: { left: 90, top: 0, right: 0, bottom: 10 },
                source: sampleData,
                xAxis:
                    {
                        dataField: 'Country',
                        showGridLines: true,
                        flip: false
                    },
                colorScheme: 'scheme01',
                seriesGroups:
                    [
                        {
                            type: 'column',
                            orientation: 'horizontal',
                            columnsGapPercent: 100,
                            toolTipFormatSettings: { thousandsSeparator: ',' },
                            valueAxis:
                            {
                                flip: true,
                                unitInterval: 100000000,
                                maxValue: 1500000000,
                                displayValueAxis: true,
                                description: '',
                                formatFunction: function (value) {
                                    return parseInt(value / 1000000);
                                }
                            },
                            series: [
                                    { dataField: 'Population', displayText: 'Population (millions)' }
                                ]
                        }
                    ]
            };

            // setup the chart
            $('#chartContainer').jqxChart(settings);
        });
    </script>     
<style>
.overlay_fix {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100000;
    opacity: 0;
    display: none;
}
</style>
    
</head>
<body>

<h1>Resize</h1>
<p>http://jsfiddle.net/cnb8eL9a/</p>
<p>http://www.codeproject.com/Articles/24123/Drag-and-Drop-with-Persistence-using-JQuery</p>

<div id="widget-list">
	<ul>
    
	<li class="sglwidgets" data-row="6" data-col="6" data-sizex="2" data-sizey="2">
    	
        <p class="title">Bar</p>
        
        <div class="big">
            <p class="content">
                <iframe src="bakaeto.htm" style="width:100%; height:290px;">
                  <p>Your browser does not support iframes.</p>
                </iframe>
            </p>
        </div>
         <div class="overlay_fix"> </div>
    </li>
  
    <li class="sglwidgets " data-row="6" data-col="6" data-sizex="2" data-sizey="2">
        <p class="title">Staff List</p>
        <div class="small">
            <p class="content">
                <ul>
                    <li>Suzie Billips</li>
                    <li>Sherri Tworek</li>
                    <li>Larue Gaspard</li>
                    <li>Debroah Nestle</li>
                    <li>Lillian Langston</li>
                    <li>Delphine Keach</li>
                    <li>Mirta Laver</li>
                    <li>Drucilla Ve	nema</li>
                </ul>
            </p>        
        </div>

    </li>
    <li class="sglwidgets" data-row="6" data-col="6" data-sizex="2" data-sizey="2">
        <p class="title">Staff Info</p>
      <div class="big">
          <p class="content">
            <div id="demo"></div>	
          </p>

	</div>
    </li>
    </ul>
</div>

<div class="gridster" id="widgets-area">
	<ul>
       </ul>
</div>
 

</body>
</html>
Posted
Comments
Member 10312045 14-Sep-14 10:42am    
Here's my code for drag and drop:

var overlay_fix_start = function() {
$('.overlay_fix').show();
}

var overlay_fix_stop = function() {
$('.overlay_fix').hide();
};

$(document).ready(function() {

//Drag and drop
$(".gridster ul").gridster({
widget_base_dimensions: [90, 10],
widget_margins: [5, 5],
min_cols: 6,
avoid_overlapped_widgets: true,
resize: {
enabled: false,
draggable: {
start: overlay_fix_start,
stop: overlay_fix_stop
}

}
})
var gridster = $(".gridster ul").gridster().data('gridster');

<!--sets the draggable-->
$(".sglwidgets").draggable({helper:'clone'});
//$(".multiwidgets").draggable();

<!--sets the droppable-->
$(".gridster ").droppable({
accept:".sglwidgets",

drop: function (event, ui) {

var droppedWidget = $(ui.draggable).clone();

//declare box size, initial box size
var boxWidth = 2;
var boxHeight = 10;

//Test if a value of the dropped widget matched or not
if( $(droppedWidget).find(".big").html()){
boxWidth = 10;
boxHeight = 15
}
else {
boxWidth = 3;
boxHeight = 8;
}



//Add the widget depending on the value
//var widget = gridster.add_widget(droppedWidget, boxWidth,/*->this height*/ 20);
var widget = gridster.add_widget(droppedWidget, boxWidth,boxHeight);

//widget.dblclick(function (widget) {
// widget = gridster.remove_widget(this);
//
// });
}
});
<!--/sets the droppable-->
});

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900