Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContextMenu: Add scrolling demo for .Net MVC and Core #3203

Merged
merged 5 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions MVCDemos/Content/DemosStyles/ContextMenu/Scrolling.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.target-area {
color: var(--dx-color-text);
background-color: var(--dx-color-border);
height: 300px;
max-width: 600px;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
15 changes: 12 additions & 3 deletions MVCDemos/Controllers/ContextMenuController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DevExtreme.AspNet.Data;
using DevExtreme.AspNet.Mvc;
using DevExtreme.MVC.Demos.Models.SampleData;
using System.Web.Mvc;

namespace DevExtreme.MVC.Demos.Controllers {
Expand All @@ -9,8 +9,17 @@ public ActionResult Basics() {
return View();
}

public ActionResult Scrolling() {
return View();
}

public ActionResult Templates() {
return View();
}

[HttpGet]
public ActionResult GetScrollingProducts(DataSourceLoadOptions loadOptions) {
return Json(DataSourceLoader.Load(ContextMenuData.Products, loadOptions), JsonRequestBehavior.AllowGet);
}
}
}
4 changes: 4 additions & 0 deletions MVCDemos/DevExtreme.MVC.Demos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,9 @@
<Compile Include="Models\OrgItems.cs" />
<Compile Include="Models\ContextMenuItem.cs" />
<Compile Include="Models\RowReorderingTask.cs" />
<Compile Include="Models\ContextMenuScrollingItem.cs" />
<Compile Include="Models\SampleData\ActiveCompanies.cs" />
<Compile Include="Models\SampleData\ContextMenuData.cs" />
<Compile Include="Models\SampleData\AdaptabilityAppointments.cs" />
<Compile Include="Models\SampleData\AgendaTasks.cs" />
<Compile Include="Models\SampleData\AnnotationData.cs" />
Expand Down Expand Up @@ -678,6 +680,7 @@
<DependentUpon>Northwind.mdf</DependentUpon>
</Content>
<Content Include="Content\demo-template.css" />
<Content Include="Content\DemosStyles\ContextMenu\Scrolling.css" />
<Content Include="Content\DemosStyles\Charts\AxisCustomPosition.css" />
<Content Include="Content\DemosStyles\Charts\CustomAnnotations.css" />
<Content Include="Content\DemosStyles\Charts\CustomLegendMarkers.css" />
Expand Down Expand Up @@ -1946,6 +1949,7 @@
<Content Include="Views\Lookup\Basics.cshtml" />
<Content Include="Views\Gallery\ItemTemplate.cshtml" />
<Content Include="Views\ContextMenu\Basics.cshtml" />
<Content Include="Views\ContextMenu\Scrolling.cshtml" />
<Content Include="Views\Charts\PiesWithEqualSize.cshtml" />
<Content Include="Views\Charts\AxisLabelsOverlapping.cshtml" />
<Content Include="Views\ContextMenu\Templates.cshtml" />
Expand Down
10 changes: 10 additions & 0 deletions MVCDemos/Models/ContextMenuScrollingItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace DevExtreme.MVC.Demos.Models {
public class ContextMenuScrollingItem {
public string text { get; set; }
public IEnumerable<ContextMenuScrollingItem> items { get; set; }
}
}
1,243 changes: 1,243 additions & 0 deletions MVCDemos/Models/SampleData/ContextMenuData.cs

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions MVCDemos/Views/ContextMenu/Scrolling.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="target-area">
Right click here to show the context menu
</div>

@(Html.DevExtreme().ContextMenu()
.Width(200)
.Target(".target-area")
.OnItemClick("contextMenu_ItemClick")
.DataSource(d => d.Mvc().LoadAction("GetScrollingProducts"))
)

<script>
function contextMenu_ItemClick(e) {
if(!e.itemData.Items) {
DevExpress.ui.notify(`The "${e.itemData.text}" item was clicked`, "success", 1500);
}
}
</script>
16 changes: 13 additions & 3 deletions NetCoreDemos/Controllers/ContextMenuController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DevExtreme.AspNet.Data;
using DevExtreme.AspNet.Mvc;
using DevExtreme.NETCore.Demos.Models.SampleData;
using Microsoft.AspNetCore.Mvc;

namespace DevExtreme.NETCore.Demos.Controllers {
Expand All @@ -9,8 +9,18 @@ public ActionResult Basics() {
return View();
}

public ActionResult Scrolling() {
return View();
}

public ActionResult Templates() {
return View();
}

[HttpGet]

public ActionResult GetScrollingProducts(DataSourceLoadOptions loadOptions) {
return Json(DataSourceLoader.Load(ContextMenuData.Products, loadOptions));
}
}
}
10 changes: 10 additions & 0 deletions NetCoreDemos/Models/ContextMenuScrollingItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace DevExtreme.NETCore.Demos.Models {
public class ContextMenuScrollingItem {
public string text { get; set; }
public IEnumerable<ContextMenuScrollingItem> items { get; set; }
}
}
Loading
Loading