Skip to content

DevExpress-Examples/diagram-how-to-integrate-the-widget-into-blazor-applications

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Diagram - How to integrate the widget into Blazor applications

Requirements

This example illustrates a possible way to integrate the Diagram widget into Blazor applications. This can be done as follows:

  1. Create a new Blazor application using recommendations from the following topic: Get started with ASP.NET Core Blazor.
  2. Install the necessary DevExtreme and Diagram resources by following steps from the following help topic: Getting Started with Diagram.
  3. Register the resources from the previous step. In Blazor server applications, use the Pages/_Host.cshtml file's HEAD section. In Blazor WebAssembly, use the wwwroot/index.html file's HEAD section.
<head>
    <!--...-->
    <link rel="stylesheet" href="https://cdn3.devexpress.com/jslib/20.1.4/css/dx.common.css">
    <link rel="stylesheet" href="https://cdn3.devexpress.com/jslib/20.1.4/css/dx.light.css">
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    <link rel="stylesheet" href="https://cdn3.devexpress.com/jslib/20.1.4/css/dx-diagram.min.css">
    <script src="https://cdn3.devexpress.com/jslib/20.1.4/js/dx-diagram.min.js"></script>
    <script type="text/javascript" src="js/diagram-init.js"></script>
    <script type="text/javascript" src="https://cdn3.devexpress.com/jslib/20.1.4/js/dx.all.js"></script>
</head>
  1. Create the *wwwroot/js/diagram-init.js file and implement the logic to initialize the Diagram widget:
window.JsFunctions = {
    InitDiagram: function () {
        var diagram = $("#diagram").dxDiagram()
            .dxDiagram("instance");

        $.ajax({
            url: "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/data/diagram-flow.json",
            dataType: "text",
            success: function (data) {
                diagram.import(data);
            }
        });
    }
};
  1. Invoke the created InitDiagram method in the OnAfterRender lifecycle event handler:
protected override void OnAfterRender(bool firstRender)
{
	JSRuntime.InvokeAsync<object>("JsFunctions.InitDiagram");
}

Files to look at:

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •