GridTable.js 1.5 KB
define(["utils"], function (_u) {
    'use strict';

    function GridTable() {
        this.store = {};
    }

    GridTable.prototype = {
        transferToVM: function (dm) {
            var btns = dm.btn_datas;
            var gtHeight = "height:auto;";
            var autoHeight = true;
            var fixedColumn = 0;
            var cols = dm.gw_datas.map(function (d, i) {
                return {
                    text: d.columnText,
                    width: d.columnWidth && _u.toPixel(d.columnWidth, "width"),
                    fixedColumn: i < fixedColumn
                };
            });

            if(dm.gtHeight) {
                gtHeight = _u.toPixel(dm.gtHeight, "height");
                autoHeight = false;
            }

            return {
            	normalSearch: {
            		hide: dm.hiddenSearch == 1,
            		tip: dm.searchTips
            	},
            	advancedSearch: {
            		enable: dm.advancedSearch == 1,
            		title: dm.asBigTitle || "高级检索"
            	},
                btns: btns.map(function (btn) {
                    return { text: btn.btnText };
                }),
                options: {
                	width: _u.toPixel(dm.gtWidth || "100%", "width"),
                	height: gtHeight,
                	autoHeight: autoHeight,
                },
                headerView: {
                	normal: cols,
                	fixed: cols.slice(0, fixedColumn)
                }
            }
        }
    };

    return GridTable;
});