Skip to content

Commit

Permalink
Merge pull request #15 from automagic/GridRequestExtensions
Browse files Browse the repository at this point in the history
Grid request extensions
  • Loading branch information
rwhitmire committed Feb 20, 2014
2 parents 52e3bdd + 5c83c9c commit accc137
Show file tree
Hide file tree
Showing 9 changed files with 2,755 additions and 417 deletions.
25 changes: 22 additions & 3 deletions KendoGridBinder.Examples/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ public HomeController(IEmployeeRepository employeeRepository)
_employeeRepository = employeeRepository;
}

public ActionResult Index()
{
public ActionResult Index()
{
ViewBag.Callback = "Grid";
return View();
}

public ActionResult Index2()
{
ViewBag.Callback = "Grid2";
return View("Index");
}

public ActionResult About()
Expand All @@ -32,6 +39,18 @@ public JsonResult Grid(KendoGridRequest request)
var employees = _employeeRepository.GetAll();
var data = new KendoGrid<Employee>(request, employees);
return Json(data);
}
}

[HttpPost]
public JsonResult Grid2(KendoGridRequest request)
{
var sort = request.GetSorting();
var filter = request.GetFiltering<Employee>();

var employees = _employeeRepository.GetPaged(request.Skip, request.Take, sort, filter);
var count = _employeeRepository.GetCount(filter);

return Json(new KendoGrid<Employee>(employees, count));
}
}
}
2,279 changes: 2,279 additions & 0 deletions KendoGridBinder.Examples/Dynamic Expressions.html

Large diffs are not rendered by default.

348 changes: 177 additions & 171 deletions KendoGridBinder.Examples/KendoGridBinder.Examples.csproj

Large diffs are not rendered by default.

48 changes: 34 additions & 14 deletions KendoGridBinder.Examples/Models/EmployeeRepository.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
using System.Collections.Generic;

using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic;

namespace KendoGridBinder.Examples.Models
{
public class EmployeeRepository : IEmployeeRepository
{
readonly KendoDataContext _db = new KendoDataContext();

public IEnumerable<Employee> GetAll()
{
return _db.Employees;
}
}

{
public class EmployeeRepository : IEmployeeRepository
{
private readonly KendoDataContext _db = new KendoDataContext();

public IEnumerable<Employee> GetAll()
{
return _db.Employees;
}

public IEnumerable<Employee> GetPaged(int skip, int take, string sort, string filter)
{
// using pattern to demonstrate scenario where IQueryable is evaluated in a different context / scope
using(var db = new KendoDataContext()){
return db.Employees.Where(filter).OrderBy(sort).Skip(skip).Take(take).ToList();
}
}

public int GetCount(string filter)
{
using (var db = new KendoDataContext())
{
return db.Employees.Where(filter).Count();
}
}
}

public interface IEmployeeRepository
{
IEnumerable<Employee> GetAll();
IEnumerable<Employee> GetAll();
IEnumerable<Employee> GetPaged(int skip, int take, string sort, string filter);
int GetCount(string filter);
}
}
6 changes: 3 additions & 3 deletions KendoGridBinder.Examples/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<script type="text/javascript">
$(document).ready(function () {
var url = '@Url.Action("Grid")';
var url = '@Url.Action(ViewBag.Callback)';
var dataSource = new kendo.data.DataSource({
serverPaging: true,
Expand All @@ -21,8 +21,8 @@
}
},
schema: {
data: 'data',
total: 'total',
data: 'Data',
total: 'Total',
model: {
id: 'Id',
fields: {
Expand Down
158 changes: 79 additions & 79 deletions KendoGridBinder.Examples/Web.config
Original file line number Diff line number Diff line change
@@ -1,80 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<connectionStrings>
<add name="KendoDataContext" connectionString="Data Source=|DataDirectory|Employees.sdf" providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="1.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.data>
</system.data>
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<connectionStrings>
<add name="KendoDataContext" connectionString="Data Source=|DataDirectory|Employees.sdf" providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="1.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.data>
</system.data>
</configuration>
23 changes: 12 additions & 11 deletions KendoGridBinder.Examples/packages.config
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="4.3.1" />
<package id="jQuery" version="1.7.1" />
<package id="jQuery.Validation" version="1.9" />
<package id="KendoUIWeb" version="2012.1.322" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
<package id="MiniProfiler" version="2.0.1" />
<package id="MiniProfiler.EF" version="2.0.2" />
<package id="MiniProfiler.MVC3" version="2.0.1" />
<package id="WebActivator" version="1.5" />
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DynamicQuery" version="1.0" targetFramework="net40" />
<package id="EntityFramework" version="4.3.1" />
<package id="jQuery" version="1.7.1" />
<package id="jQuery.Validation" version="1.9" />
<package id="KendoUIWeb" version="2012.1.322" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
<package id="MiniProfiler" version="2.0.1" />
<package id="MiniProfiler.EF" version="2.0.2" />
<package id="MiniProfiler.MVC3" version="2.0.1" />
<package id="WebActivator" version="1.5" />
</packages>
Loading

0 comments on commit accc137

Please sign in to comment.