|
<EjsSidebar Width="250px" @ref="sidebarObj" Changed="open">
</EjsSidebar>
<div style="text-align: center;" class="e-droppable">
<EjsDashboardLayout @ref="dashboard" ID="dashboard" CellSpacing="@(new double[]{20 ,20 })" Columns="4" CellAspectRatio="2" AllowDragging="true">
</EjsDashboardLayout>
</div> |
|
public async Task dragStop(DragAndDropEventArgs args)
{
// Fetch the Dropped node Details
var nodeDetails = args.DraggedNodeData.Text;
var value = JsonConvert.SerializeObject(args.Event);
Dictionary<string, dynamic> eventParameters = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(value);
// Pass the value to the client side to identify the dropped panel.
var value1 = await JSRuntime.InvokeAsync<int>("AddPanel", eventParameters);
// If the dashboard panel index is 0. update the panel content.
if (value1 == 0)
{
ContentValue =@<div style="height:90%; width:100%;">
@nodeDetails
<Error></Error>
</div>;
}
// If the dashboard panel index is 1. update the panel content.
else if (value1 == 1)
{
panelcontent2 =@<div>@nodeDetails<EjsButton Content="Panel2"></EjsButton></div>;
}
// Remove the cloned node.
args.Cancel = true;
}
function AddPanel(args) {
var dashboard = document.getElementById("dashboard").ej2_instances[0];
// Find out the Dashboard Layout
var element = document.elementFromPoint(args.clientX, args.clientY);
// Check the dropped panel is DashboardLayout panel.
if (element.closest(".e-panel")) {
for (i = 0; i < dashboard.panelCollection.length; i++) {
if (element.closest(".e-panel").id == dashboard.panelCollection[i].id) {
// Get the index of the Dropped panel
var index = i;
}
}
}
// Return the index of the dashboardLyaout panel
return index;
} |
|
public void AddPanel(Microsoft.AspNetCore.Components.Web.MouseEventArgs args)
{
this.chartId = "linearChart" + this.dashboard.Panels.Count().ToString();
this.addPanel = new PanelModel()
{
SizeX = 2,
MaxSizeX = 1,
SizeY = 1,
Row = 0,
Col = 1,
Content =@<div style="height:100%; width:100%;">
<Error></Error>
</div>,
Header = @<div>Header Content</div>,
};
this.dashboard.AddPanel(this.addPanel);
} |
|
<EjsTreeView TValue="TreeItem" AllowDragAndDrop="true">
<TreeViewEvents TValue="TreeItem" OnNodeDragged="dragStop"></TreeViewEvents>
</EjsTreeView>
public void dragStop(DragAndDropEventArgs args)
{
// Fetch the Dropped node Details
var nodeDetails = args.DraggedNodeData.Text;
// Add the panel based on node text.
if (nodeDetails == "Local Disk (C:)")
{
this.addPanel = new PanelModel()
{
SizeX = 2,
MaxSizeX = 1,
SizeY = 1,
Row = 0,
Col = 1,
Content =@<div style="height:100%; width:100%;">
<Error></Error>
</div>,
Header = @<div>Header Content</div>,
};
this.dashboard.AddPanel(this.addPanel);
}
} |
|
@using Syncfusion.Blazor.Layouts
<SfDashboardLayout CellSpacing="@(new double[]{10 ,10 })" Columns="5" AllowDragging="true">
<DashboardLayoutPanels>
<DashboardLayoutPanel CssClass="e-drag-restrict">
<ContentTemplate><div>Restrict dragging</div></ContentTemplate>
</DashboardLayoutPanel>
<DashboardLayoutPanel SizeX=2 SizeY=2 Col=1 CssClass="e-drag-restrict">
<ContentTemplate><div>Restrict dragging</div></ContentTemplate>
</DashboardLayoutPanel>
<DashboardLayoutPanel SizeY=2 Col=3>
<ContentTemplate><div>2</div></ContentTemplate>
</DashboardLayoutPanel>
<DashboardLayoutPanel Row=1>
<ContentTemplate><div>3</div></ContentTemplate>
</DashboardLayoutPanel>
</DashboardLayoutPanels>
</SfDashboardLayout> |
Good day
I am trying to drag items from the Tree to the Dashboard but the code does not run pass the InvokeAsync.
I used this project
DashBoardLayout1796148004.zip
and updated it from EJ* to Sf*
Is there something I am missing?
|
<SfSidebar Width="250px" @ref="sidebarObj" Changed="open">
<ChildContent>
<div>
<TreeViewEvents TValue="TreeItem" OnNodeDragged="dragStop"></TreeViewEvents>
. . .
</div>
</ChildContent>
</SfSidebar>
<div style="text-align: center;" class="e-droppable">
<SfDashboardLayout @ref="dashboard" AllowDragging="true">
. . .
</SfDashboardLayout>
</div>
@code {
public async Task dragStop(DragAndDropEventArgs args)
{
List<string> id = new List<string>();
for (var i = 0; i < this.dashboard.Panels.Count; i++)
{
id.Add(this.dashboard.Panels[i].Id); //to get the panels id.
}
var value1 = await JSRuntime.InvokeAsync<int>("AddPanel",args,id);
}
} |
|
<script>
window.AddPanel = (args,inst)=>{
var element = document.elementFromPoint(args.left, args.top);
// Check the dropped panel is DashboardLayout panel.
if (element.closest(".e-panel")) {
for (i = 0; i < inst.length; i++) {
if (element.closest(".e-panel").id == inst[i]) {
// Get the index of the Dropped panel
var index = i;
}
}
}
// Return the index of the dashboardLyaout panel
return index;
}
</script> |