Skip to content

Commit 2452229

Browse files
author
matanasov
authored
Merge pull request telerik#12 from telerik/field-selection
Add example for selection by field in grid
2 parents 788bfb8 + 0ba7e0f commit 2452229

21 files changed

+1004
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25420.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SelectionByField", "SelectionByField\SelectionByField.csproj", "{AF35255D-58DD-4D20-8481-CE214ACF6697}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{AF35255D-58DD-4D20-8481-CE214ACF6697}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{AF35255D-58DD-4D20-8481-CE214ACF6697}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{AF35255D-58DD-4D20-8481-CE214ACF6697}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{AF35255D-58DD-4D20-8481-CE214ACF6697}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Web;
2+
using System.Web.Optimization;
3+
4+
namespace SelectionPersistence
5+
{
6+
public class BundleConfig
7+
{
8+
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
9+
public static void RegisterBundles(BundleCollection bundles)
10+
{
11+
bundles.Add(new StyleBundle("~/Content/css").Include(
12+
"~/Content/bootstrap.css",
13+
"~/Content/site.css"));
14+
}
15+
}
16+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.Mvc;
6+
using System.Web.Routing;
7+
8+
namespace SelectionPersistence
9+
{
10+
public class RouteConfig
11+
{
12+
public static void RegisterRoutes(RouteCollection routes)
13+
{
14+
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
15+
16+
routes.MapRoute(
17+
name: "Default",
18+
url: "{controller}/{action}/{id}",
19+
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
20+
);
21+
}
22+
}
23+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
3+
<TelemetryInitializers>
4+
<Add Type="Microsoft.ApplicationInsights.DependencyCollector.HttpDependenciesParsingTelemetryInitializer, Microsoft.AI.DependencyCollector"/>
5+
<Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer"/>
6+
<Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureWebAppRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer"/>
7+
<Add Type="Microsoft.ApplicationInsights.WindowsServer.BuildInfoConfigComponentVersionTelemetryInitializer, Microsoft.AI.WindowsServer"/>
8+
</TelemetryInitializers>
9+
<TelemetryModules>
10+
<Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector"/>
11+
<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
12+
<!--
13+
Use the following syntax here to collect additional performance counters:
14+
15+
<Counters>
16+
<Add PerformanceCounter="\Process(??APP_WIN32_PROC??)\Handle Count" ReportAs="Process handle count" />
17+
...
18+
</Counters>
19+
20+
PerformanceCounter must be either \CategoryName(InstanceName)\CounterName or \CategoryName\CounterName
21+
22+
NOTE: performance counters configuration will be lost upon NuGet upgrade.
23+
24+
The following placeholders are supported as InstanceName:
25+
??APP_WIN32_PROC?? - instance name of the application process for Win32 counters.
26+
??APP_W3SVC_PROC?? - instance name of the application IIS worker process for IIS/ASP.NET counters.
27+
??APP_CLR_PROC?? - instance name of the application CLR process for .NET counters.
28+
-->
29+
</Add>
30+
<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector"/>
31+
<Add Type="Microsoft.ApplicationInsights.WindowsServer.DeveloperModeWithDebuggerAttachedTelemetryModule, Microsoft.AI.WindowsServer"/>
32+
<Add Type="Microsoft.ApplicationInsights.WindowsServer.UnhandledExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
33+
<Add Type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
34+
</TelemetryModules>
35+
<TelemetryProcessors>
36+
<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryProcessor, Microsoft.AI.PerfCounterCollector"/>
37+
<Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
38+
<MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
39+
</Add>
40+
</TelemetryProcessors>
41+
<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel"/>
42+
<!--
43+
Learn more about Application Insights configuration with ApplicationInsights.config here:
44+
http://go.microsoft.com/fwlink/?LinkID=513840
45+
46+
Note: If not present, please add <InstrumentationKey>Your Key</InstrumentationKey> to the top of this file.
47+
--></ApplicationInsights>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
using Kendo.Mvc.Extensions;
2+
using Kendo.Mvc.UI;
3+
using SelectionPersistence.Models;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Web;
8+
using System.Web.Mvc;
9+
10+
namespace SelectionPersistence.Controllers
11+
{
12+
public class HomeController : Controller
13+
{
14+
public static List<Product> products = new List<Product>();
15+
public ActionResult Index()
16+
{
17+
if(products.Count == 0)
18+
{
19+
for (int i = 0; i < 200; i++)
20+
{
21+
products.Add(new Product()
22+
{
23+
ProductID = i,
24+
ProductName = "ProductName" + i.ToString(),
25+
UnitPrice = i * 3.14,
26+
UnitsInStock = i * 5,
27+
Discontinued = (i % 2 == 0) ? true : false
28+
});
29+
}
30+
}
31+
32+
return View(AreAllSelected());
33+
}
34+
35+
public bool AreAllSelected()
36+
{
37+
var selectAll = true;
38+
foreach (var product in products)
39+
{
40+
if (product.Discontinued == false)
41+
{
42+
selectAll = false;
43+
break;
44+
}
45+
}
46+
return selectAll;
47+
}
48+
49+
public ActionResult Get_Products([DataSourceRequest] DataSourceRequest dsRequest)
50+
{
51+
var result = products.ToDataSourceResult(dsRequest);
52+
return Json(result);
53+
}
54+
55+
public ActionResult Select_Products(List<Product> productsList)
56+
{
57+
foreach (Product product in productsList)
58+
{
59+
var toUpdate = products.FirstOrDefault(p => p.ProductID == product.ProductID);
60+
toUpdate.Discontinued = product.Discontinued;
61+
62+
}
63+
return Json(AreAllSelected());
64+
65+
}
66+
67+
public ActionResult Select_AllProducts(bool checkAll)
68+
{
69+
foreach (var product in products)
70+
{
71+
product.Discontinued = checkAll;
72+
}
73+
return new EmptyResult();
74+
}
75+
}
76+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%@ Application Codebehind="Global.asax.cs" Inherits="SelectionPersistence.MvcApplication" Language="C#" %>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.Mvc;
6+
using System.Web.Optimization;
7+
using System.Web.Routing;
8+
9+
namespace SelectionPersistence
10+
{
11+
public class MvcApplication : System.Web.HttpApplication
12+
{
13+
protected void Application_Start()
14+
{
15+
AreaRegistration.RegisterAllAreas();
16+
RouteConfig.RegisterRoutes(RouteTable.Routes);
17+
BundleConfig.RegisterBundles(BundleTable.Bundles);
18+
}
19+
}
20+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
6+
namespace SelectionPersistence.Models
7+
{
8+
public class Product
9+
{
10+
public int ProductID { get; set; }
11+
public string ProductName { get; set; }
12+
public double UnitPrice { get; set; }
13+
public int UnitsInStock { get; set; }
14+
public bool Discontinued { get; set; }
15+
}
16+
}
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Your ASP.NET application</title>
6+
<style>
7+
body {
8+
background: #fff;
9+
color: #505050;
10+
font: 14px 'Segoe UI', tahoma, arial, helvetica, sans-serif;
11+
margin: 20px;
12+
padding: 0;
13+
}
14+
15+
#header {
16+
background: #efefef;
17+
padding: 0;
18+
}
19+
20+
h1 {
21+
font-size: 48px;
22+
font-weight: normal;
23+
margin: 0;
24+
padding: 0 30px;
25+
line-height: 150px;
26+
}
27+
28+
p {
29+
font-size: 20px;
30+
color: #fff;
31+
background: #969696;
32+
padding: 0 30px;
33+
line-height: 50px;
34+
}
35+
36+
#main {
37+
padding: 5px 30px;
38+
}
39+
40+
.section {
41+
width: 21.7%;
42+
float: left;
43+
margin: 0 0 0 4%;
44+
}
45+
46+
.section h2 {
47+
font-size: 13px;
48+
text-transform: uppercase;
49+
margin: 0;
50+
border-bottom: 1px solid silver;
51+
padding-bottom: 12px;
52+
margin-bottom: 8px;
53+
}
54+
55+
.section.first {
56+
margin-left: 0;
57+
}
58+
59+
.section.first h2 {
60+
font-size: 24px;
61+
text-transform: none;
62+
margin-bottom: 25px;
63+
border: none;
64+
}
65+
66+
.section.first li {
67+
border-top: 1px solid silver;
68+
padding: 8px 0;
69+
}
70+
71+
.section.last {
72+
margin-right: 0;
73+
}
74+
75+
ul {
76+
list-style: none;
77+
padding: 0;
78+
margin: 0;
79+
line-height: 20px;
80+
}
81+
82+
li {
83+
padding: 4px 0;
84+
}
85+
86+
a {
87+
color: #267cb2;
88+
text-decoration: none;
89+
}
90+
91+
a:hover {
92+
text-decoration: underline;
93+
}
94+
</style>
95+
</head>
96+
<body>
97+
98+
<div id="header">
99+
<h1>Your ASP.NET application</h1>
100+
<p>Congratulations! You've created a project</p>
101+
</div>
102+
103+
<div id="main">
104+
<div class="section first">
105+
<h2>This application consists of:</h2>
106+
<ul>
107+
<li>Sample pages showing basic nav between Home, About, and Contact</li>
108+
<li>Theming using <a href="http://go.microsoft.com/fwlink/?LinkID=615519">Bootstrap</a></li>
109+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615520">Authentication</a>, if selected, shows how to register and sign in</li>
110+
<li>ASP.NET features managed using <a href="http://go.microsoft.com/fwlink/?LinkID=320756">NuGet</a></li>
111+
</ul>
112+
</div>
113+
114+
<div class="section">
115+
<h2>Customize app</h2>
116+
<ul>
117+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615541">Get started with ASP.NET MVC</a></li>
118+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615523">Change the site's theme</a></li>
119+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615524">Add more libraries using NuGet</a></li>
120+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615542">Configure authentication</a></li>
121+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615526">Customize information about the website users</a></li>
122+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615527">Get information from social providers</a></li>
123+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615528">Add HTTP services using ASP.NET Web API</a></li>
124+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615529">Secure your web API</a></li>
125+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615530">Add real-time web with ASP.NET SignalR</a></li>
126+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615531">Add components using Scaffolding</a></li>
127+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615532">Test your app with Browser Link</a></li>
128+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615533">Share your project</a></li>
129+
</ul>
130+
</div>
131+
132+
<div class="section">
133+
<h2>Deploy</h2>
134+
<ul>
135+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615534">Ensure your app is ready for production</a></li>
136+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615535">Microsoft Azure</a></li>
137+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615536">Hosting providers</a></li>
138+
</ul>
139+
</div>
140+
141+
<div class="section last">
142+
<h2>Get help</h2>
143+
<ul>
144+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615537">Get help</a></li>
145+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=615538">Get more templates</a></li>
146+
</ul>
147+
</div>
148+
</div>
149+
150+
</body>
151+
</html>

0 commit comments

Comments
 (0)