Skip to content

Commit a204b00

Browse files
authored
Merge pull request telerik#29 from telerik/alternating-rows-example-modified-for-local-data
chore:alternating-rows-exmpl-modified-for-local-data
2 parents 632f4d2 + 06e2cc7 commit a204b00

12 files changed

+72
-1827
lines changed

grid/alternating-rows/KendoUIMVC5/Controllers/HomeController.cs

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,62 @@ namespace KendoUIMVC5.Controllers
1111
{
1212
public class HomeController : Controller
1313
{
14+
public static ICollection<Student> students = new List<Student>();
1415
public ActionResult Index()
1516
{
1617
ViewBag.Message = "Welcome to ASP.NET MVC!";
1718

1819
return View();
1920
}
2021

21-
public ActionResult Orders_Read([DataSourceRequest]DataSourceRequest request)
22+
public HomeController()
2223
{
23-
using (var northwind = new NorthwindEntities())
24+
var names = new List<string> { "John", "Jane", "Jeremy", "James" };
25+
var lastNames = new List<string> { "Hammont", "Clarkson", "May", "Hennethon" };
26+
var random = new Random();
27+
if (students.Count == 0)
2428
{
25-
return Json(northwind.Orders.ToDataSourceResult(request, o => new
29+
for (int i = 1; i < 50; i++)
30+
{
31+
students.Add(new Student
2632
{
27-
o.OrderID,
28-
o.Freight,
29-
o.OrderDate,
30-
o.ShipName,
31-
o.ShipCity
32-
}));
33+
Age = random.Next(1, 20),
34+
Birthday = new DateTime(random.Next(1950, 2018), random.Next(1, 12), random.Next(1, 27)),
35+
FirstName = names[random.Next(0, 4)],
36+
LastName = lastNames[random.Next(0, 4)],
37+
Id = i
38+
});
39+
}
3340
}
3441
}
3542

43+
public ActionResult GetStudents([DataSourceRequest] DataSourceRequest request)
44+
{
45+
46+
return Json(students.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
47+
}
48+
49+
public ActionResult EditStudent(Student student)
50+
{
51+
students.Where(x => x.Id == student.Id).Select(x => student);
52+
53+
return Json(student);
54+
}
55+
56+
public ActionResult CreateStudent(Student student)
57+
{
58+
student.Id = students.Count + 1;
59+
students.Add(student);
60+
61+
return Json(student);
62+
}
63+
64+
public ActionResult DestroyStudent(Student student)
65+
{
66+
students.Remove(students.First(x => x.Id == student.Id));
67+
68+
return Json(student);
69+
}
70+
3671
}
3772
}

grid/alternating-rows/KendoUIMVC5/KendoUIMVC5.csproj

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
<IISExpressAnonymousAuthentication />
2121
<IISExpressWindowsAuthentication />
2222
<IISExpressUseClassicPipelineMode />
23+
<Use64BitIISExpress />
24+
<UseGlobalApplicationHostFile />
2325
</PropertyGroup>
2426
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2527
<DebugSymbols>true</DebugSymbols>
@@ -121,24 +123,7 @@
121123
<Compile Include="Global.asax.cs">
122124
<DependentUpon>Global.asax</DependentUpon>
123125
</Compile>
124-
<Compile Include="Models\Northwind.Context.cs">
125-
<AutoGen>True</AutoGen>
126-
<DesignTime>True</DesignTime>
127-
<DependentUpon>Northwind.Context.tt</DependentUpon>
128-
</Compile>
129-
<Compile Include="Models\Northwind.cs">
130-
<AutoGen>True</AutoGen>
131-
<DesignTime>True</DesignTime>
132-
<DependentUpon>Northwind.tt</DependentUpon>
133-
</Compile>
134-
<Compile Include="Models\Northwind.Designer.cs">
135-
<AutoGen>True</AutoGen>
136-
<DesignTime>True</DesignTime>
137-
<DependentUpon>Northwind.edmx</DependentUpon>
138-
</Compile>
139-
<Compile Include="Models\Order.cs">
140-
<DependentUpon>Northwind.tt</DependentUpon>
141-
</Compile>
126+
<Compile Include="Models\Student.cs" />
142127
<Compile Include="Properties\AssemblyInfo.cs" />
143128
</ItemGroup>
144129
<ItemGroup>
@@ -149,16 +134,6 @@
149134
<Content Include="favicon.ico" />
150135
<Content Include="Global.asax" />
151136
<Content Include="Content\Site.css" />
152-
<Content Include="Models\Northwind.Context.tt">
153-
<Generator>TextTemplatingFileGenerator</Generator>
154-
<DependentUpon>Northwind.edmx</DependentUpon>
155-
<LastGenOutput>Northwind.Context.cs</LastGenOutput>
156-
</Content>
157-
<Content Include="Models\Northwind.tt">
158-
<Generator>TextTemplatingFileGenerator</Generator>
159-
<DependentUpon>Northwind.edmx</DependentUpon>
160-
<LastGenOutput>Northwind.cs</LastGenOutput>
161-
</Content>
162137
<Content Include="Scripts\kendo.modernizr.custom.js" />
163138
<Content Include="Scripts\_references.js" />
164139
<Content Include="Web.config" />
@@ -189,17 +164,6 @@
189164
<ItemGroup>
190165
<Content Include="packages.config" />
191166
</ItemGroup>
192-
<ItemGroup>
193-
<EntityDeploy Include="Models\Northwind.edmx">
194-
<Generator>EntityModelCodeGenerator</Generator>
195-
<LastGenOutput>Northwind.Designer.cs</LastGenOutput>
196-
</EntityDeploy>
197-
</ItemGroup>
198-
<ItemGroup>
199-
<Content Include="Models\Northwind.edmx.diagram">
200-
<DependentUpon>Northwind.edmx</DependentUpon>
201-
</Content>
202-
</ItemGroup>
203167
<ItemGroup>
204168
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
205169
</ItemGroup>

grid/alternating-rows/KendoUIMVC5/Models/Northwind.Context.cs

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)