• About Morris Development
  • A Focus for Cloud Efficiency
    • Microsoft Azure
    • Amazon Web Services
  • What our Clients Say
  • Our Products
    • PreschoolDB
    • WebinarDB
  • Contact Us

Morris Development

Custom System Development and Integration

October 7, 2015

Grid Data with Angular’s Kendo Directives

note:You might want to consider ObservableArrays instead of Kendo Datasources.
Writing Angular Controllers in Typescript for Kendo Grids – Dealing with Data

One of the biggest problems we’ve run into is accessing and updating grid data using data from our Angular DataFactories. Here’s how we have had the most success:

Here is a simple labor grid.

 

That’s pretty damn easy, isn’t it?

Now, to populate it is actually a bit tricky. The way to do it is to use the exact same kendo UI format in building the options and send them to the grid as a function of the scope. (which is pretty standard). The trick is the data needs to be in the READ of the transport object.

read: function (options) {
                        datalayer.PackageLaborItems(package_id).
                            then(function (results) {
                                options.success(results.data)
                            })

that datalayer is our factory object, byt you could just as easily use $http. The trick is to set the options.success to the dataset you get in return.

so, rather than setting the data of the grid to an actual dataset, that read has to be a function call that returns a dataset.



    $scope.getLaborGridOptions = function () {
        return {
            dataSource: {
                type: 'json',
                transport: {
                    read: function (options) {
                        datalayer.PackageLaborItems(package_id).
                            then(function (results) {
                                options.success(results.data)
                            })
                    },
                },
                schema: {
                    model: {
                        id: "id",
                        fields: {
                            id: { editable: false }
                            , Employee: { type: "string", editable: true }
                            , Task: { type: "string", editable: true }
                            , Quantity: { type: "number", editable: true }
                            , Hours: { type: "number", editable: true }
                            , Rate: { type: "number", editable: true }
                        }
                    }
                }
            },
            ,
            columns: [
                { hidden: true, field: "id", title: "id" },
                {field: "Employee", title: "Staff" },
                {field: "Task", title: "Task"},
                {field: "Quantity", title: "Quantity" },
                {field: "Hours",title: "Hours"  },
                { field: "Rate",title: "Rate" } 
            ]

        }
    }

Here are the factories we have for this module, so you can see how it works:

var app = angular.module('myapp', ['kendo.directives', 'ngMessages'])
.factory('datalayer', function ($q, $timeout, $http) {
    return {
        SaveRecord: function (Package) {
            var url = '/api/Package.ashx?package_id=' + package_id + '&sid=' + session_id
            return $http.post(url, Package);
        },
        CommissionTypes: function () {
            return $http.get('/api/CommisionTypes.ashx?sid=' + session_id);
        },
        GetPackage: function (package_id) {
            return $http.get('/api/Package.ashx?package_id=' + package_id + '&sid=' + session_id);
        },
        PackageItems: function (package_id) {
            return $http.get('/api/PackageItems.ashx?package_id=' + package_id + '&sid=' + session_id);
        },
        PackageLaborItems: function (package_id) {
            return $http.get('/api/PackageLaborItems.ashx?package_id=' + package_id + '&sid=' + session_id);
        },
        LaborItemsAdd: function (dataset) {
            return $http.post('/api/JobLaborHandler.ashx?sid=' + session_id, dataset)
        }
        ,
        JobRooms: function (orderid) {
            return $http.get('/api/JobRoomHandler.ashx?oid='+orderid+'&sid=' + session_id)
        }

    };
});

This guy had the original idea: http://www.markschabacker.com/blog/2015/07/31/angular-service-as-kendo-datasource/

Article by MacGyver / AngularJS, Kendo

About MacGyver

I've worked with database systems for over 20 years, and started my own company in 2000. Almost all my business consists of internal database systems, either ERP or CRM. My programming is primarily in Angular / Microsoft C# and MS SQL.

About This Site

Morris Development has been specializing in internal database system design and integration since 1999. We provide long-term management and support of secure data systems for many businesses as well as developing the more complex code structures for ERP systems like Intellievent, Apidas, and AVMS.

This site is primarily for our developers to keep track up various technologies and updates that are used by Morris Development.

Training

Integrating Angular Microsite with .Net

Private Data Caching with Google Storage

Continuous Deployment for Production Releases?

Azure Websites – the perfect Angular host

Angular 2

  • Angular 2 Authentication
  • Angular Command Line Interface
  • Material Design for Angular
  • Using Observables in Angular 2

Mentors

  • Ben Nadel
  • Dan Wahlin
  • Deborah Kurata
  • John Papa

Staff

  • Dan Morris

Training

  • Google Development Courses
  • Microsoft Virtual Academy
  • PluralSight
  • Test Deep Links

© 2025 · Morris Development