コード例 #1
0
        protected override async Task OnParametersSetAsync()
        {
            _renderFragments = new QueryDictionary <RenderFragment>();
            foreach (var column in GridComponent.Grid.Columns)
            {
                // Name must have a non empty value
                if (string.IsNullOrWhiteSpace(column.Name))
                {
                    column.Name = Guid.NewGuid().ToString();
                }

                if (((ICGridColumn)column).SubGrids != null)
                {
                    var values = ((ICGridColumn)column).GetSubGridKeyValues(Item);
                    var grid   = await((ICGridColumn)column).SubGrids(values.Values.ToArray(), true, true, true, true) as ICGrid;
                    grid.Direction   = GridComponent.Grid.Direction;
                    grid.FixedValues = values;
                    VariableReference reference = new VariableReference();
                    if (Children.ContainsKey(column.Name))
                    {
                        Children[column.Name] = reference;
                    }
                    else
                    {
                        Children.Add(column.Name, reference);
                    }
                    if (_renderFragments.ContainsKey(column.Name))
                    {
                        _renderFragments[column.Name] = CreateSubGridComponent(grid, reference);
                    }
                    else
                    {
                        _renderFragments.Add(column.Name, CreateSubGridComponent(grid, reference));
                    }
                }
                else if (column.UpdateComponentType != null)
                {
                    VariableReference reference = new VariableReference();
                    if (Children.ContainsKey(column.Name))
                    {
                        Children[column.Name] = reference;
                    }
                    else
                    {
                        Children.Add(column.Name, reference);
                    }
                    if (_renderFragments.ContainsKey(column.Name))
                    {
                        _renderFragments[column.Name] = GridCellComponent <T> .CreateComponent(_sequence,
                                                                                               GridComponent, column.UpdateComponentType, column, Item, null, true, reference);
                    }
                    else
                    {
                        _renderFragments.Add(column.Name, GridCellComponent <T> .CreateComponent(_sequence,
                                                                                                 GridComponent, column.UpdateComponentType, column, Item, null, true, reference));
                    }
                }
            }
            _tabGroups = GridComponent.Grid.Columns
                         .Where(r => !string.IsNullOrWhiteSpace(r.TabGroup) && _renderFragments.Keys.Any(s => s.Equals(r.Name)))
                         .Select(r => r.TabGroup).Distinct();

            _shouldRender = true;
        }
コード例 #2
0
        protected override async Task OnParametersSetAsync()
        {
            _renderFragments = new QueryDictionary <RenderFragment>();
            foreach (var column in GridComponent.Grid.Columns)
            {
                // Name must have a non empty value
                if (string.IsNullOrWhiteSpace(column.Name))
                {
                    column.Name = Guid.NewGuid().ToString();
                }

                if (((ICGridColumn)column).SubGrids != null)
                {
                    var values = ((ICGridColumn)column).GetSubGridKeyValues(Item);
                    var grid   = await((ICGridColumn)column).SubGrids(values.Values.ToArray(), true, true, true, true) as ICGrid;
                    grid.Direction   = GridComponent.Grid.Direction;
                    grid.FixedValues = values;
                    VariableReference reference = new VariableReference();
                    if (Children.ContainsKey(column.Name))
                    {
                        Children[column.Name] = reference;
                    }
                    else
                    {
                        Children.Add(column.Name, reference);
                    }
                    if (_renderFragments.ContainsKey(column.Name))
                    {
                        _renderFragments[column.Name] = CreateSubGridComponent(grid, reference);
                    }
                    else
                    {
                        _renderFragments.Add(column.Name, CreateSubGridComponent(grid, reference));
                    }
                }
                else if (column.UpdateComponentType != null)
                {
                    VariableReference reference = new VariableReference();
                    if (Children.ContainsKey(column.Name))
                    {
                        Children[column.Name] = reference;
                    }
                    else
                    {
                        Children.Add(column.Name, reference);
                    }
                    if (_renderFragments.ContainsKey(column.Name))
                    {
                        _renderFragments[column.Name] = GridCellComponent <T> .CreateComponent(_sequence,
                                                                                               GridComponent, column.UpdateComponentType, column, Item, null, true, reference);
                    }
                    else
                    {
                        _renderFragments.Add(column.Name, GridCellComponent <T> .CreateComponent(_sequence,
                                                                                                 GridComponent, column.UpdateComponentType, column, Item, null, true, reference));
                    }
                }
            }
            _tabGroups = GridComponent.Grid.Columns
                         .Where(r => !string.IsNullOrWhiteSpace(r.TabGroup) && _renderFragments.Keys.Any(s => s.Equals(r.Name)))
                         .Select(r => r.TabGroup).Distinct();

            if (((CGrid <T>)GridComponent.Grid).ButtonCrudComponents != null && ((CGrid <T>)GridComponent.Grid).ButtonCrudComponents.Count() > 0)
            {
                foreach (var key in ((CGrid <T>)GridComponent.Grid).ButtonCrudComponents.Keys)
                {
                    var buttonCrudComponent = ((CGrid <T>)GridComponent.Grid).ButtonCrudComponents.Get(key);
                    if ((buttonCrudComponent.UpdateMode != null && buttonCrudComponent.UpdateMode(Item)) ||
                        (buttonCrudComponent.UpdateModeAsync != null && await buttonCrudComponent.UpdateModeAsync(Item)) ||
                        (buttonCrudComponent.GridMode.HasFlag(GridMode.Update)))
                    {
                        _buttonCrudComponentVisibility.Add(key, true);
                    }
                    else
                    {
                        _buttonCrudComponentVisibility.Add(key, false);
                    }
                }
            }

            foreach (var column in GridComponent.Grid.Columns)
            {
                if (((IGridColumn <T>)column).IsSelectColumn.IsSelectKey)
                {
                    var selectItem = await((IGridColumn <T>)column).SelectItemExpr(Item);
                    SelectItems.Add(column.Name, selectItem);
                }
            }

            _shouldRender = true;
        }