all files / grid/models/ row.js

100% Statements 35/35
100% Branches 8/8
100% Functions 8/8
100% Lines 34/34
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49   53316× 53316×   64× 64× 372× 64×                          
define(["require", "exports", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Row = (function () {
        function Row(options, parent) {
            ej2_base_1.merge(this, options);
            this.parent = parent;
        }
        Row.prototype.clone = function () {
            var row = new Row({});
            ej2_base_1.merge(row, this);
            row.cells = this.cells.map(function (cell) { return cell.clone(); });
            return row;
        };
        Row.prototype.setRowValue = function (data) {
            if (!this.parent) {
                return;
            }
            var key = this.data[this.parent.getPrimaryKeyFieldNames()[0]];
            this.parent.setRowData(key, data);
        };
        Row.prototype.setCellValue = function (field, value) {
            if (!this.parent) {
                return;
            }
            var isValDiff = !(this.data["" + field].toString() === value.toString());
            if (isValDiff) {
                var pKeyField = this.parent.getPrimaryKeyFieldNames()[0];
                var key = this.data["" + pKeyField];
                this.parent.setCellValue(key, field, value);
                this.makechanges(pKeyField, this.data);
            }
            else {
                return;
            }
        };
        Row.prototype.makechanges = function (key, data) {
            if (!this.parent) {
                return;
            }
            var gObj = this.parent;
            var dataManager = gObj.getDataModule().dataManager;
            dataManager.update(key, data);
        };
        return Row;
    }());
    exports.Row = Row;
});