1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | "use strict";
|
8 | var __extends = (this && this.__extends) || (function () {
|
9 | var extendStatics = Object.setPrototypeOf ||
|
10 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
11 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
12 | return function (d, b) {
|
13 | extendStatics(d, b);
|
14 | function __() { this.constructor = d; }
|
15 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
16 | };
|
17 | })();
|
18 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
19 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
20 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
21 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
22 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
23 | };
|
24 | var __metadata = (this && this.__metadata) || function (k, v) {
|
25 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
26 | };
|
27 | Object.defineProperty(exports, "__esModule", { value: true });
|
28 | var utils_1 = require("../../utils");
|
29 | var gridOptionsWrapper_1 = require("../../gridOptionsWrapper");
|
30 | var context_1 = require("../../context/context");
|
31 | var rowNodeBlock_1 = require("../cache/rowNodeBlock");
|
32 | var rowRenderer_1 = require("../../rendering/rowRenderer");
|
33 | var InfiniteBlock = (function (_super) {
|
34 | __extends(InfiniteBlock, _super);
|
35 | function InfiniteBlock(pageNumber, params) {
|
36 | var _this = _super.call(this, pageNumber, params) || this;
|
37 | _this.cacheParams = params;
|
38 | return _this;
|
39 | }
|
40 | InfiniteBlock.prototype.createBlankRowNode = function (rowIndex) {
|
41 | var rowNode = _super.prototype.createBlankRowNode.call(this, rowIndex);
|
42 | rowNode.uiLevel = 0;
|
43 | this.setIndexAndTopOnRowNode(rowNode, rowIndex);
|
44 | return rowNode;
|
45 | };
|
46 | InfiniteBlock.prototype.setDataAndId = function (rowNode, data, index) {
|
47 | if (utils_1.Utils.exists(data)) {
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | rowNode.setDataAndId(data, index.toString());
|
53 | }
|
54 | else {
|
55 | rowNode.setDataAndId(undefined, undefined);
|
56 | }
|
57 | };
|
58 | InfiniteBlock.prototype.setRowNode = function (rowIndex, rowNode) {
|
59 | _super.prototype.setRowNode.call(this, rowIndex, rowNode);
|
60 | this.setIndexAndTopOnRowNode(rowNode, rowIndex);
|
61 | };
|
62 | InfiniteBlock.prototype.init = function () {
|
63 | _super.prototype.init.call(this, {
|
64 | context: this.context,
|
65 | rowRenderer: this.rowRenderer
|
66 | });
|
67 | };
|
68 | InfiniteBlock.prototype.getNodeIdPrefix = function () {
|
69 | return null;
|
70 | };
|
71 | InfiniteBlock.prototype.getRow = function (displayIndex) {
|
72 | return this.getRowUsingLocalIndex(displayIndex);
|
73 | };
|
74 | InfiniteBlock.prototype.setIndexAndTopOnRowNode = function (rowNode, rowIndex) {
|
75 | rowNode.setRowIndex(rowIndex);
|
76 | rowNode.rowTop = this.cacheParams.rowHeight * rowIndex;
|
77 | };
|
78 | InfiniteBlock.prototype.loadFromDatasource = function () {
|
79 | var _this = this;
|
80 |
|
81 |
|
82 |
|
83 |
|
84 | var params = {
|
85 | startRow: this.getStartRow(),
|
86 | endRow: this.getEndRow(),
|
87 | successCallback: this.pageLoaded.bind(this, this.getVersion()),
|
88 | failCallback: this.pageLoadFailed.bind(this),
|
89 | sortModel: this.cacheParams.sortModel,
|
90 | filterModel: this.cacheParams.filterModel,
|
91 | context: this.gridOptionsWrapper.getContext()
|
92 | };
|
93 | if (utils_1.Utils.missing(this.cacheParams.datasource.getRows)) {
|
94 | console.warn("ag-Grid: datasource is missing getRows method");
|
95 | return;
|
96 | }
|
97 |
|
98 | var getRowsParams = utils_1.Utils.getFunctionParameters(this.cacheParams.datasource.getRows);
|
99 | if (getRowsParams.length > 1) {
|
100 | console.warn('ag-grid: It looks like your paging datasource is of the old type, taking more than one parameter.');
|
101 | console.warn('ag-grid: From ag-grid 1.9.0, now the getRows takes one parameter. See the documentation for details.');
|
102 | }
|
103 |
|
104 | setTimeout(function () {
|
105 | _this.cacheParams.datasource.getRows(params);
|
106 | }, 0);
|
107 | };
|
108 | __decorate([
|
109 | context_1.Autowired('gridOptionsWrapper'),
|
110 | __metadata("design:type", gridOptionsWrapper_1.GridOptionsWrapper)
|
111 | ], InfiniteBlock.prototype, "gridOptionsWrapper", void 0);
|
112 | __decorate([
|
113 | context_1.Autowired('context'),
|
114 | __metadata("design:type", context_1.Context)
|
115 | ], InfiniteBlock.prototype, "context", void 0);
|
116 | __decorate([
|
117 | context_1.Autowired('rowRenderer'),
|
118 | __metadata("design:type", rowRenderer_1.RowRenderer)
|
119 | ], InfiniteBlock.prototype, "rowRenderer", void 0);
|
120 | __decorate([
|
121 | context_1.PostConstruct,
|
122 | __metadata("design:type", Function),
|
123 | __metadata("design:paramtypes", []),
|
124 | __metadata("design:returntype", void 0)
|
125 | ], InfiniteBlock.prototype, "init", null);
|
126 | return InfiniteBlock;
|
127 | }(rowNodeBlock_1.RowNodeBlock));
|
128 | exports.InfiniteBlock = InfiniteBlock;
|