Example #1
0
        public UniGridCol <T> AddCol(string description = null, Func <T, object> commonFormat = null)
        {
            var c = new UniGridCol <T>(description, commonFormat);

            Cols.Add(c);
            return(c);
        }
Example #2
0
        /// <summary>
        /// Call this if you are rendering table manually - prepares RenderData
        /// </summary>
        public void PrepareRenderData()
        {
            // generate unique "id" for columns
            foreach (var c in Cols.Where(x => x.Description != null))
            {
                c.ID = new string(c.Description.Where(x => (x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z')).Take(3).ToArray());
            }
            for (int i = 0; i < Cols.Count; i++)
            {
                UniGridCol <T> col = Cols[i];
                if (string.IsNullOrEmpty(col.ID) || Cols.Any(x => x != col && x.ID == col.ID))
                {
                    col.ID += i + 1;
                }
            }

            RenderData  = InputData;
            RecordCount = RenderData.Count();

            if (!string.IsNullOrEmpty(OrderColumn))
            {
                UniGridCol <T> col = Cols.FirstOrDefault(x => x.ID == OrderColumn);
                if (col != null)
                {
                    RenderData = OrderBy(RenderData, col.SortExpression, !OrderIsDescending);
                }
            }
        }