
- var app = angular.module('MyApp', ['datatables']);
- app.controller('homeCtrl', ['$scope', '$http', 'DTOptionsBuilder', 'DTColumnBuilder',
- function ($scope, $http, DTOptionsBuilder, DTColumnBuilder) {
- $scope.dtColumns = [
- DTColumnBuilder.newColumn("FirstName", "First Name"),
- DTColumnBuilder.newColumn("LastName", "Last Name"),
- DTColumnBuilder.newColumn("Age", "Age"),
- DTColumnBuilder.newColumn("Address", "Address"),
- DTColumnBuilder.newColumn("City", "City"),
- DTColumnBuilder.newColumn("State", "State")
- ]
- $scope.dtOptions = DTOptionsBuilder.newOptions().withOption('ajax', {
- url: "/home/getdata",
- type: "POST"
- })
- .withPaginationType('full_numbers')
- .withDisplayLength(10);
- }])
- var app = angular.module('MyApp', ['datatables']);
- app.controller('homeCtrl', ['$scope', '$http', 'DTOptionsBuilder', 'DTColumnBuilder',
- function ($scope, $http, DTOptionsBuilder, DTColumnBuilder)
I have mentioned the columns of table (Entity Types) as uploaded using enitity data model using scope object. The scope is a JavaScript object which basically binds the "controller" and the "view". One can define member variables in the scope within the controller which can then be accessed by the view.
- $scope.dtColumns = [
- DTColumnBuilder.newColumn("FirstName", "First Name"),
- DTColumnBuilder.newColumn("LastName", "Last Name"),
- DTColumnBuilder.newColumn("Age", "Age"),
- DTColumnBuilder.newColumn("Address", "Address"),
- DTColumnBuilder.newColumn("City", "City"),
- DTColumnBuilder.newColumn("State", "State")
- ]
- $scope.dtOptions = DTOptionsBuilder.newOptions().withOption('ajax', {
- url: "/home/getdata",
- type: "POST"
- })
- .withPaginationType('full_numbers')
- .withDisplayLength(10);
- public ActionResult Angular()
- {
- return View();
- }
- public ActionResult getData()
- {
- using (SatyaDBEntities dc = new SatyaDBEntities())
- {
- return Json(dc.employees.ToList());
- }
- }
- @{
- ViewBag.Title = "Angular Datatables";
- }
- <h2 style="color: blue">Satyaprakash-Angular Datatable Using EF and Bootstrap</h2>
- <link href="~/css/bootstrap.css" rel="stylesheet" />
- <link href="~/css/jquery.dataTables.min.css" rel="stylesheet" />
- <script src="~/Scripts/jquery.js"></script>
- <script src="~/Scripts/jquery.dataTables.js"></script>
- <script src="~/Scripts/angular.js"></script>
- <script src="~/Scripts/angular-datatables.js"></script>
- <script src="~/Scripts/myApp.js"></script>
- <div ng-app="MyApp" class="container">
- <div ng-controller="homeCtrl">
- <table id="entry-grid" datatable="" dt-options="dtOptions" dt-columns="dtColumns" class="table table-hover"></table>
- </div>
- </div>
- <link href="~/css/bootstrap.css" rel="stylesheet" />
- <link href="~/css/jquery.dataTables.min.css" rel="stylesheet" />
- <script src="~/Scripts/jquery.js"></script>
- <script src="~/Scripts/jquery.dataTables.js"></script>
- <script src="~/Scripts/angular.js"></script>
- <script src="~/Scripts/angular-datatables.js"></script>
- <script src="~/Scripts/myApp.js"></script>
- <div ng-app="MyApp" class="container">
- <div ng-controller="homeCtrl">
- <div ng-app="MyApp" class="container">
- <div ng-controller="homeCtrl">
- <table id="entry-grid" datatable="" dt-options="dtOptions" dt-columns="dtColumns" class="table table-hover"></table>
- </div>
- </div>


- Implement the Angular Datatable using MVC and Bootstrap.
- Datatable with Bootstrap using Angular DataTables dependencies.
- Features of Datatable makes coding easier.
- Datatable using Entity Framework.


Sarathlal SaseendranPosted Nov 12, 2018, 4:35 AM EST
Very nice article