‘Packaging’ the access with database to take a lot off pressure of databse in Kendo Grid

09. August 2016 Article 4

There is not necessary to access database several times to request same data, especially for the project which has a mass of users, otherwise, it will lead to much pressure of data. This post describes one situation in my real case, which I have to get the data from SQL server to display in Kendo Grid, but at same time, I have to sum up one of column and display it on the top of Grid:

First of all, in the front-end side, ‘div’ has been created with ‘id=”totalAmount”‘ for displaying the sum of a column, and another ‘div’ with ‘id=”invoiceGrid”‘ for displaying all data.

Image 3

In Kendo code side, I packaged the access with database to avoid several times connection and assign datasource to a varibale:

Image 2

Then, trying to use this¬†object to combine data into Kendo Grid (‘id=”invoiceGrid”‘):

2016-08-09_115458

And as mentioned above, I have to sum up one column, in the returned data, I have to sum up the total amount of invoices, and display it into ‘div’ (‘id=”totalAmount”‘):

2016-08-09_115719

Until here, my task is done, but there are few tips must be listed:

  1. In Kendo Grid, we could definitely separate dataSource, and assign to variable, which could be used for many times;
  2. In this case, the returned data called ‘totalAmountJson’, which includes many arrays inside, but the number of arrays could not be got by busing ‘length’, it has to be used ‘.total()’ to count the number;
  3. And ‘totalAmoungJson.at(0)’ means the first array inside ‘totalAmountJson’ (the index is 0).

4 thoughts on “‘Packaging’ the access with database to take a lot off pressure of databse in Kendo Grid”

Leave a Reply