NGridTable.js
1.99 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
define(["utils"], function (_u) {
    'use strict';
    function NGridTable() {
        this.store = {};
    }
    NGridTable.prototype = {
        transferToVM: function (dm) {
            var btns = dm.customBtns || [],
                sourceData = dm.sourceData || {},
                sourceType = sourceData.sourceType;
            var gtHeight = "height:auto;";
            var autoHeight = true;
            var fixedColumn = 0;
            var cols = dm.showColumns.map(function (d, i) {
                return {
                    text: d.fieldTitle,
                    width: d.fieldWidth && _u.toPixel(d.fieldWidth, "width"),
                    fixedColumn: i < fixedColumn
                };
            });
            if(dm.gtHeight) {
                gtHeight = _u.toPixel(dm.gtHeight, "height");
                autoHeight = false;
            }
            return {
                dataSource: {
                    type: sourceType == 1 ? 'cube' : 'other'
                },
                quickSearch: {
                    hide: dm.quickSearch !== "1",
                    tip: dm.searchTips
                },
                advancedSearch: {
                    enable: sourceType == 1 && dm.advancedSearch == 1,
                },
                btns: btns.map(function (btn) {
                    var btnType = btn.btnType, picPath = btn.picPath || "", btnText = btn.btnText || "";
                    return {
                        type: btnType,
                        icon: btnType == "1" ? "" : picPath,
                        text: btnType == "2" ? "" : btnText
                    };
                }),
                options: {
                    width: _u.toPixel(dm.gtWidth || "100%", "width"),
                    height: gtHeight,
                    autoHeight: autoHeight,
                },
                headerView: {
                    normal: cols,
                    fixed: cols.slice(0, fixedColumn)
                }
            }
        }
    };
    return NGridTable;
});