コード例 #1
0
        public GridColumn(string data, string title, int?width, ColumnsTextAlign align = ColumnsTextAlign.None)
        {
            this.data  = data;
            this.title = title;
            this.width = width != null?Convert.ToString(width) : null;

            this.className = align != ColumnsTextAlign.None ? align.GetDescription() : null;
        }
コード例 #2
0
        public GridColumn(string data, string title, int?width, ColumnsType type = ColumnsType.None, ColumnsTextAlign align = ColumnsTextAlign.None, string render = null)
        {
            this.data  = data;
            this.title = title;
            this.width = width != null?Convert.ToString(width) : null;

            this.type = type;
            if ((type == ColumnsType.Date ||
                 type == ColumnsType.DateTime) && string.IsNullOrEmpty(render))
            {
                render = "function (data, type, full, meta) {return $.jsonDateToFormat(data";
                if (type == ColumnsType.DateTime)
                {
                    render += ",'DD/MM/YYYY HH:mm:ss'";
                }
                render += ");}";
                if (align == ColumnsTextAlign.None)
                {
                    align = ColumnsTextAlign.Center;
                }
            }

            if (type == ColumnsType.Time && string.IsNullOrEmpty(render))
            {
                render = "function (data, type, full, meta) {return $.jsonDateToFormat(data";
                if (type == ColumnsType.Time)
                {
                    render += ",'HH:mm:ss'";
                }
                render += ");}";
                if (align == ColumnsTextAlign.None)
                {
                    align = ColumnsTextAlign.Center;
                }
            }

            if ((type == ColumnsType.NumberFormat ||
                 type == ColumnsType.NumberFormat2 ||
                 type == ColumnsType.NumberFormat3 ||
                 type == ColumnsType.NumberFormat4 ||
                 type == ColumnsType.NumberFormat6 ||
                 type == ColumnsType.NumberFormat8 ||
                 type == ColumnsType.NumberFormat10
                 ) && string.IsNullOrEmpty(render))
            {
                if (align == ColumnsTextAlign.None)
                {
                    align = ColumnsTextAlign.Right;
                }
                var digitLength = 0;
                if (type == ColumnsType.NumberFormat2)
                {
                    digitLength = 2;
                }
                else if (type == ColumnsType.NumberFormat3)
                {
                    digitLength = 3;
                }
                else if (type == ColumnsType.NumberFormat4)
                {
                    digitLength = 4;
                }
                else if (type == ColumnsType.NumberFormat6)
                {
                    digitLength = 6;
                }
                else if (type == ColumnsType.NumberFormat8)
                {
                    digitLength = 8;
                }
                else if (type == ColumnsType.NumberFormat10)
                {
                    digitLength = 10;
                }

                if (digitLength > 0)
                {
                    render = "function (data, type, full, meta) {return digitsFormat(toNumberFormat(data)," + digitLength + ");}";
                }
                else
                {
                    render = "function (data, type, full, meta) {return toNumberFormat(data);}";
                }
            }

            if (type == ColumnsType.Checkbox)
            {
                if (align == ColumnsTextAlign.None)
                {
                    align = ColumnsTextAlign.Center;
                }
                render  = "function (data, type, full, meta) {";
                render += "var tag = '<i class=\"ace-icon fa fa-square-o\"></i>';";
                render += "if(data == 'Y'){";
                render += "tag = '<i class=\"ace-icon fa fa-check-square-o\"></i>';}";
                render += "return tag;}";
            }
            this.render    = render;
            this.className = align != ColumnsTextAlign.None ? align.GetDescription() : null;
        }