Пример #1
0
 /// <summary>
 /// 将object转为Data数据(List形式)
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <typeparam name="T1"></typeparam>
 /// <param name="SourceList">被赋值类</param>
 /// <param name="TragetList">源类</param>
 /// <param name="IsConvertNull">是否将Null转化给Data</param>
 /// <param name="ConvertRule">特殊转化规则key为源属性,value为目标属性</param>
 /// <param name="noValue">不进行赋值的属性名称数组</param>
 /// <returns></returns>
 public static List <T> O2D <T, T1>(this List <T> SourceList, List <T1> TragetList, bool IsConvertNull = false, List <KeyValuePair <string, string> > ConvertRule = null, string noValue = null)
 {
     if (TragetList != null)
     {
         if (SourceList == null)
         {
             SourceList = new List <T>();
         }
         for (int i = 0; i < TragetList.Count(); i++)
         {
             if (SourceList.Count() == i)
             {
                 SourceList.Add(System.Activator.CreateInstance <T>());
             }
             SourceList[i] = SourceList[i].O2D(TragetList[i], IsConvertNull, ConvertRule, noValue);
         }
     }
     return(SourceList);
 }
Пример #2
0
        //bool EnabledRender = true;

        //protected override bool ShouldRender()
        //{
        //    return EnabledRender;
        //}

        protected override Task OnParametersSetAsync()
        {
            //BlazorWindowHelper.BlazorTimeAnalyzer.LogAllAdd = true;

            bvgGrid = new BvgGrid
            {
                IsReady        = true,
                Name           = TableName,
                RowsTotalCount = SourceList.Count(),
                bvgSettings    = bvgSettings,
                AllProps       = typeof(TItem).GetProperties(BindingFlags.Public | BindingFlags.Instance),
                SortState      = Tuple.Create(false, new BvgColumn()),
            };


            bvgGrid.ColumnsOrderedList          = ColumnsHelper.GetColumnsOrderedList(bvgGrid);
            bvgGrid.ColumnsOrderedListFrozen    = bvgGrid.ColumnsOrderedList.Where(x => x.IsFrozen).ToArray();
            bvgGrid.ColumnsOrderedListNonFrozen = bvgGrid.ColumnsOrderedList.Where(x => x.IsFrozen == false).ToArray();


            ColProp[] c = bvgGrid.ColumnsOrderedList.Where(x => x.IsFrozen == false).ToArray();

            bvgGrid.NonFrozenColwidthSumsByElement = new int[c.Count()];
            int j = 0;

            for (int i = 0; i < c.Count(); i++)
            {
                j += c[i].ColWidth;
                bvgGrid.NonFrozenColwidthSumsByElement[i] = j;
            }

            c = null;


            SortedRowsList = SourceList.ToArray();

            return(base.OnParametersSetAsync());
        }
Пример #3
0
        private void Reset(bool LoadColumnsFromSettings)
        {
            FirstLoad    = true;
            ActualRender = true;

            LastHorizontalSkip = -1;

            LastHorizontalScrollPosition = 0;


            if (bvgGrid != null)
            {
                bvgGridTransferableState = new BvgGridTransferableState <TItem>(bvgGrid);
            }
            else
            {
                bvgGridTransferableState = new BvgGridTransferableState <TItem>();
            }

            bvgGrid = new BvgGrid <TItem>
            {
                IsReady         = true,
                Name            = TableName,
                RowsTotalCount  = SourceList.Count(),
                bvgSettings     = bvgSettings,
                AllProps        = typeof(TItem).GetProperties(BindingFlags.Public | BindingFlags.Instance),
                HasMeasuredRect = bvgGridTransferableState.HasMeasuredRect,
                bvgSize         = bvgGridTransferableState.bvgSize,
            };

            bvgGrid.bvgModal.bvgGrid = bvgGrid;

            if (bvgGridTransferableState.ContaintState)
            {
                bvgGrid.cssHelper = bvgGridTransferableState.cssHelper;
            }

            if (bvgGridTransferableState.ContaintState && !LoadColumnsFromSettings)
            {
                bvgGrid.ColumnsOrderedList          = bvgGridTransferableState.ColumnsOrderedList;
                bvgGrid.ColumnsOrderedListFrozen    = bvgGridTransferableState.ColumnsOrderedListFrozen;
                bvgGrid.ColumnsOrderedListNonFrozen = bvgGridTransferableState.ColumnsOrderedListNonFrozen;
            }
            else
            {
                bvgGrid.ColumnsOrderedList = ColumnsHelper <TItem> .GetColumnsOrderedList(bvgGrid);

                bvgGrid.ColumnsOrderedListFrozen    = bvgGrid.ColumnsOrderedList.Where(x => x.IsFrozen).ToArray();
                bvgGrid.ColumnsOrderedListNonFrozen = bvgGrid.ColumnsOrderedList.Where(x => x.IsFrozen == false).ToArray();
            }


            bvgGrid.UpdateNonFrozenColwidthSumsByElement();

            if (bvgSettings.SortedColumn.Item1)
            {
                bvgGrid.SortState = Tuple.Create(bvgSettings.SortedColumn.Item1, bvgSettings.SortedColumn.Item2, bvgSettings.SortedColumn.Item3);


                if (bvgSettings.SortedColumn.Item3)
                {
                    SortedRowsList = GenericAdapter <TItem> .GetSortedRowsList(SourceList.AsQueryable(), bvgSettings.SortedColumn.Item2).ToArray();
                }
                else
                {
                    SortedRowsList = GenericAdapter <TItem> .GetSortedRowsList(SourceList.AsQueryable(), bvgSettings.SortedColumn.Item2 + " desc").ToArray();
                }
            }
            else
            {
                bvgGrid.SortState = Tuple.Create(false, string.Empty, false);

                SortedRowsList = SourceList.ToArray();
            }
        }