Exemplo n.º 1
0
        private void RenderDeleteButton(GridRendererContext rendererContext, PermissionContext permissionContext)
        {
            if (!permissionContext.HasDeleteItemPermission ||
                !rendererContext.GridConfiguration.InlineEditOptions.AllowDeleting)
            {
                return;
            }

            var localActualItem = rendererContext.ActualItem;

            rendererContext.OpenElement(HtmlTagNames.Button, "action-button");
            rendererContext.AddOnClickEvent(() =>
                                            BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
            {
                rendererContext.TableDataSet.DeleteItem(localActualItem);
                rendererContext.RequestRerenderNotification?.Invoke();
            })
                                            );

            rendererContext.OpenElement(HtmlTagNames.Span, "action-button-span");
            rendererContext.OpenElement(HtmlTagNames.I, "fas fa-trash-alt");
            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();
        }
        private void RenderSortableColumnHeader(GridRendererContext rendererContext, PropertyInfo property, IGridViewColumnAnotations columnConfiguration)
        {
            rendererContext.OpenElement(HtmlTagNames.TableHeadCell, rendererContext.CssClasses.TableHeaderCell);
            rendererContext.OpenElement(HtmlTagNames.Span,
                                        rendererContext.SortingByActualColumnName ? "table-cell-head-sortable table-cell-head-sortable-active" : "table-cell-head-sortable");
            rendererContext.AddOnClickEvent(() =>
                                            BindMethods.GetEventHandlerValue(async(UIMouseEventArgs e) =>
                                                                             await rendererContext.TableDataSet.SetSortExpression(property.Name))
                                            );

            if (rendererContext.SortingByActualColumnName)
            {
                var arrowDirection = rendererContext.TableDataSet.SortingOptions.SortDescending ? "fas fa-arrow-down" : "fas fa-arrow-up";
                rendererContext.AddContent(GetColumnCaption(columnConfiguration, property));
                rendererContext.OpenElement(HtmlTagNames.I, $"table-cell-head-arrow {arrowDirection}");
                rendererContext.CloseElement();
            }
            else
            {
                rendererContext.AddContent(GetColumnCaption(columnConfiguration, property));
            }

            rendererContext.CloseElement();
            rendererContext.CloseElement();
        }
        private void RenderTab(
            GridRendererContext rendererContext,
            IMasterTableDataSet masterTableDataSet,
            ITableDataAdapter selectedDataAdapter,
            ITableDataAdapter dataAdapter)
        {
            var masterDetailRelationship = rendererContext
                                           .GridConfiguration
                                           .FindRelationshipConfiguration(dataAdapter.UnderlyingTypeOfItem);

            var localActualItem = rendererContext.ActualItem;

            rendererContext.OpenElement(HtmlTagNames.Button,
                                        selectedDataAdapter.IsForSameUnderlyingType(dataAdapter) ? "tabs-button tabs-button-active" : "tabs-button");

            rendererContext.AddOnClickEvent(() =>
                                            BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
                                                                             masterTableDataSet.SelectDataAdapter(new MasterDetailRowArguments(dataAdapter, localActualItem)))
                                            );

            rendererContext.OpenElement(HtmlTagNames.Span, "tabs-button-text");
            rendererContext.AddContent(masterDetailRelationship.DetailGridViewPageCaption(dataAdapter));
            rendererContext.CloseElement();
            rendererContext.CloseElement();
        }
Exemplo n.º 4
0
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            int ct = 0;

            if (_gameController.ClientPlayer == ClientPlayerType.Waiting)
            {
                builder.OpenElement(ct++, "text");
                builder.AddAttribute(ct++, "x", _offsetX - _colWidth / 2);
                builder.AddAttribute(ct++, "y", _vertexLength * 5);

                builder.AddAttribute(ct++, "style", $"fill:black;font-size:{GetFontSize()}px;");
                builder.AddContent(ct++, "Waiting for oponent....");
                builder.CloseElement();
            }
            else
            {
                Console.WriteLine($"Player={_gameController.Game.CurrentPlayer.Color} Stage={_gameController.Game.TurnStage} TurnNo={_gameController.Game.TurnNo}");

                builder.OpenElement(ct++, "svg");
                builder.AddAttribute(ct++, "height", _height);
                builder.AddAttribute(ct++, "width", _width);
                builder.AddAttribute(ct++, "style", "text-align:center;");
                builder.AddAttribute(ct++, "onclick", BindMethods.GetEventHandlerValue <UIMouseEventArgs>(HandleClick));
                DrawBoard(builder, ref ct);
                builder.CloseElement();
            }
            base.BuildRenderTree(builder);
        }
Exemplo n.º 5
0
        protected override void BuildRenderTreeInternal(GridRendererContext rendererContext, PermissionContext permissionContext)
        {
            rendererContext.OpenElement(HtmlTagNames.TableRow, rendererContext.CssClasses.TableRow);

            var localActualItem = rendererContext.ActualItem;

            rendererContext.AddOnClickEvent(() =>
                                            BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
            {
                rendererContext.TableDataSet
                .GridViewEvents
                .OnItemClicked?.Invoke(new ItemClickedArgs {
                    Item = localActualItem
                });
            }));

            foreach (var property in rendererContext.GridItemProperties)
            {
                rendererContext.ActualColumnName = property.Name;
                rendererContext.ActualColumnPropertyCanBeEdited = property.CanWrite;

                gridPartRenderers.ForEach(renderer => renderer.BuildRendererTree(rendererContext, permissionContext));
            }

            rendererContext.CloseElement();

            gridPartRenderersAfter.ForEach(renderer => renderer.BuildRendererTree(rendererContext, permissionContext));
        }
Exemplo n.º 6
0
        private void RenderGroupingFooterPart(GridRendererContext rendererContext)
        {
            rendererContext.OpenElement(HtmlTagNames.Div, rendererContext.CssClasses.FooterCssClasses.GroupingPartWrapper);
            rendererContext.OpenElement(HtmlTagNames.Select, "group-select");
            rendererContext.AddAttribute(HtmlAttributes.Id, GroupingSelectId);
            rendererContext.AddOnChangeEvent(() =>
                                             BindMethods.GetEventHandlerValue(async(UIChangeEventArgs e) =>
            {
                rendererContext.TableDataSet.GroupingOptions.SetGroupedProperty(e.Value.ToString());
                await rendererContext.TableDataSet.GoToPage(0);
                rendererContext.RequestRerenderNotification?.Invoke();
            })
                                             );

            if (!rendererContext.TableDataSet.GroupingOptions.IsGroupingActive)
            {
                rendererContext.OpenElement(HtmlTagNames.Option);
                rendererContext.AddAttribute(HtmlAttributes.Disabled, true);
                rendererContext.AddContent(GroupByPlaceholder);
                rendererContext.CloseElement();
            }

            foreach (var groupableProperty in rendererContext.TableDataSet.GroupingOptions.GroupableProperties)
            {
                rendererContext.OpenElement(HtmlTagNames.Option);

                if (groupableProperty == rendererContext.TableDataSet.GroupingOptions.GroupedProperty)
                {
                    rendererContext.AddAttribute(HtmlAttributes.Selected, true);
                }

                rendererContext.AddAttribute(HtmlAttributes.Value, groupableProperty.Name);
                rendererContext.AddContent(rendererContext.GetColumnCaption(groupableProperty.Name) ?? groupableProperty.Name);
                rendererContext.CloseElement();
            }

            rendererContext.CloseElement();
            rendererContext.CloseElement();

            if (rendererContext.TableDataSet.GroupingOptions.IsGroupingActive)
            {
                rendererContext.OpenElement(HtmlTagNames.Button, "action-button");
                rendererContext.AddOnClickEvent(() =>
                                                BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
                {
                    rendererContext.TableDataSet.GroupingOptions.DeactivateGrouping();
                    rendererContext.RequestRerenderNotification?.Invoke();
                })
                                                );

                rendererContext.OpenElement(HtmlTagNames.Span, "action-button-span");
                rendererContext.OpenElement(HtmlTagNames.I, "fas fa-times");
                rendererContext.CloseElement();
                rendererContext.CloseElement();
                rendererContext.CloseElement();
            }
        }
Exemplo n.º 7
0
        private void RenderGroupingFooterPart(GridRendererContext rendererContext)
        {
            rendererContext.OpenElement(HtmlTagNames.Div, rendererContext.CssClasses.FooterCssClasses.GroupingPartWrapper);
            rendererContext.OpenElement(HtmlTagNames.Select);
            rendererContext.AddAttribute(HtmlAttributes.Id, groupingSelectId);

            rendererContext.AddOnChangeEvent(() =>
                                             BindMethods.GetEventHandlerValue(async(UIChangeEventArgs e) =>
            {
                string propertyName = e.Value.ToString();
                if (propertyName == noGroupingOptionText)
                {
                    rendererContext.TableDataSet.GroupingOptions.DeactivateGrouping();
                }
                else
                {
                    rendererContext.TableDataSet.GroupingOptions.SetGroupedProperty(propertyName);
                }
                await rendererContext.TableDataSet.GoToPage(0);
                rendererContext.RequestRerenderNotification?.Invoke();
            })
                                             );


            if (!rendererContext.TableDataSet.GroupingOptions.IsGroupingActive)
            {
                rendererContext.OpenElement(HtmlTagNames.Option);
                rendererContext.AddAttribute(HtmlAttributes.Disabled, true);
                rendererContext.AddContent(groupByPlaceholder);
                rendererContext.CloseElement();
            }
            else
            {
                rendererContext.OpenElement(HtmlTagNames.Option);
                rendererContext.AddAttribute(HtmlAttributes.Value, string.Empty);
                rendererContext.AddContent(noGroupingOptionText);
                rendererContext.CloseElement();
            }

            foreach (var groupableProperty in rendererContext.TableDataSet.GroupingOptions.GroupableProperties)
            {
                rendererContext.OpenElement(HtmlTagNames.Option);

                if (groupableProperty == rendererContext.TableDataSet.GroupingOptions.GroupedProperty)
                {
                    rendererContext.AddAttribute(HtmlAttributes.Selected, true);
                }

                rendererContext.AddAttribute(HtmlAttributes.Value, groupableProperty.Name);
                rendererContext.ActualColumnName = groupableProperty.Name;
                var displayedGroupablePropertyName = rendererContext.ActualColumnConfiguration?.Caption ?? groupableProperty.Name;
                rendererContext.AddContent(displayedGroupablePropertyName);
                rendererContext.CloseElement();
            }
            rendererContext.CloseElement();
            rendererContext.CloseElement();
        }
Exemplo n.º 8
0
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            base.BuildRenderTree(builder);

            LoadStateIfExists();

            var rendererBuilder = new BlazorRendererTreeBuilder(builder);

            rendererBuilder
            .OpenElement(HtmlTagNames.Button, filterIsApplied ? "action-button action-button-small action-button-filter-active" : "action-button action-button-small")
            .AddAttribute(HtmlJSEvents.OnClick,
                          BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
            {
                filterDefinitionOpened = !filterDefinitionOpened;
            })
                          )
            .OpenElement(HtmlTagNames.Span)
            .OpenElement(HtmlTagNames.I, "fas fa-filter")
            .CloseElement()
            .CloseElement()
            .CloseElement();


            rendererBuilder.OpenElement(HtmlTagNames.Div,
                                        filterDefinitionOpened
                ? parser != TryParseBool
                        ? $"{WrapperCssClass} {WrapperCssClass}-open"
                        : $"{WrapperCssClass} {WrapperCssClass}-open {WrapperCssCheckboxClass}"
                : $"{WrapperCssClass}");

            if (parser == TryParseBool)
            {
                BuildRendererTreeForCheckbox(rendererBuilder);
            }
            else
            {
                BuildRendererTreeForFilterOperations(rendererBuilder);
                BuildRendererTreeForInputs(rendererBuilder);
            }

            if (parser != TryParseBool)
            {
                rendererBuilder.OpenElement(HtmlTagNames.Div, "filter-buttons");
                rendererBuilder.OpenElement(HtmlTagNames.Button, "btn btn-light filter-buttons-clear")
                .AddOnClickEvent(() =>
                                 BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
                {
                    ClearFilter();
                })
                                 )
                .AddContent("Clear")
                .CloseElement()
                .CloseElement();
            }

            rendererBuilder.CloseElement();
        }
Exemplo n.º 9
0
            public void Compose(TreeComposer composer)
            {
                if (!this.OnClick.IsDefault())
                {
                    Debug.Assert(this.OnClickAsync.IsDefault(), "Cannot set both sync and async versions of this event");
                    composer.builder.AddAttribute(composer.sequence++, "onclick", BindMethods.GetEventHandlerValue(this.OnClick));
                }

                if (!this.OnClickAsync.IsDefault())
                {
                    Debug.Assert(this.OnClick.IsDefault(), "Cannot set both sync and async versions of this event");
                    composer.builder.AddAttribute(composer.sequence++, "onclick", BindMethods.GetEventHandlerValue(this.OnClickAsync));
                }

                if (!this.OnInput.IsDefault())
                {
                    composer.builder.AddAttribute(composer.sequence++, "oninput", BindMethods.GetEventHandlerValue(this.OnInput));
                }

                if (!this.OnMouseWheelAsync.IsDefault())
                {
                    composer.builder.AddAttribute(composer.sequence++, "onmousewheel", BindMethods.GetEventHandlerValue(this.OnMouseWheelAsync));
                }

                if (!this.OnKeyDown.IsDefault())
                {
                    Debug.Assert(this.OnKeyDownAsync.IsDefault(), "Cannot set both sync and async versions of this event");
                    composer.builder.AddAttribute(composer.sequence++, "onkeydown", BindMethods.GetEventHandlerValue(this.OnKeyDown));
                }

                if (!this.OnKeyDownAsync.IsDefault())
                {
                    Debug.Assert(this.OnKeyDown.IsDefault(), "Cannot set both sync and async versions of this event");
                    composer.builder.AddAttribute(composer.sequence++, "onkeydown", BindMethods.GetEventHandlerValue(this.OnKeyDownAsync));
                }

                if (!this.OnKeyUp.IsDefault())
                {
                    composer.builder.AddAttribute(composer.sequence++, "onkeyup", BindMethods.GetEventHandlerValue(this.OnKeyUp));
                }

                if (!this.OnMouseDown.IsDefault())
                {
                    composer.builder.AddAttribute(composer.sequence++, "onmousedown", BindMethods.GetEventHandlerValue(this.OnMouseDown));
                }

                if (!this.OnMouseUp.IsDefault())
                {
                    composer.builder.AddAttribute(composer.sequence++, "onmouseup", BindMethods.GetEventHandlerValue(this.OnMouseUp));
                }

                if (!this.OnMouseMove.IsDefault())
                {
                    composer.builder.AddAttribute(composer.sequence++, "onmousemove", BindMethods.GetEventHandlerValue(this.OnMouseMove));
                }
            }
Exemplo n.º 10
0
        protected override void BuildRenderTreeInternal(GridRendererContext rendererContext, PermissionContext permissionContext)
        {
            using (new MeasurableScope(sw => logger.LogInformation($"Grid grouped body rendering duration {sw.ElapsedMilliseconds}ms")))
            {
                rendererContext.OpenElement(HtmlTagNames.TableBody, rendererContext.CssClasses.TableBody);
                foreach (var group in rendererContext.TableDataSet.GroupedItems)
                {
                    try
                    {
                        rendererContext.OpenElement(HtmlTagNames.TableRow, rendererContext.CssClasses.TableGroupRow);
                        rendererContext.OpenElement(HtmlTagNames.TableColumn, rendererContext.CssClasses.TableGroupRowCell);
                        rendererContext.AddAttribute(HtmlAttributes.Colspan, rendererContext.NumberOfColumns);
                        rendererContext.OpenElement(HtmlTagNames.Button, "pagination-button");
                        rendererContext.AddOnClickEvent(() =>
                                                        BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
                        {
                            rendererContext.TableDataSet.ToggleGroupRow(group.Key);
                            rendererContext.RequestRerenderNotification?.Invoke();
                        })
                                                        );
                        rendererContext.OpenElement(HtmlTagNames.Span, "pagination-button-arrow");
                        rendererContext.OpenElement(HtmlTagNames.I, !group.IsCollapsed ? "fas fa-angle-down" : "fas fa-angle-right");
                        rendererContext.CloseElement();
                        rendererContext.CloseElement();
                        rendererContext.CloseElement();
                        rendererContext.AddMarkupContent($"\t<b>{rendererContext.TableDataSet.GroupingOptions.GroupedProperty.Name}:</b> {group.Key.ToString()}\t");
                        rendererContext.OpenElement(HtmlTagNames.I);
                        rendererContext.AddContent($"({group.Count})");
                        rendererContext.CloseElement();


                        if (!group.IsCollapsed)
                        {
                            var dataAdapter        = tableDataAdapterProvider.CreateCollectionTableDataAdapter(rendererContext.TableDataSet.UnderlyingTypeOfItem(), group);
                            var masterTableFeature = rendererContext.FlexGridContext.Features.Get <IMasterTableFeature>();
                            dataAdapter = tableDataAdapterProvider.CreateMasterTableDataAdapter(dataAdapter, masterTableFeature);

                            rendererContext.AddGridViewComponent(dataAdapter);
                        }

                        rendererContext.CloseElement();
                        rendererContext.CloseElement();
                    }
                    catch (Exception ex)
                    {
                        logger.LogError($"Error occured during rendering grouped grid view body. Ex: {ex}");

                        throw ex;
                    }
                }

                rendererContext.CloseElement();
            }
        }
        private void RenderSaveButton(GridRendererContext rendererContext)
        {
            rendererContext.OpenElement(HtmlTagNames.Button, "action-button");
            rendererContext.AddOnClickEvent(() =>
                                            BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
                                                                             rendererContext.TableDataSet.SaveItem(rendererContext.PropertyValueAccessor))
                                            );

            rendererContext.OpenElement(HtmlTagNames.Span, "action-button-span");
            rendererContext.OpenElement(HtmlTagNames.I, "fas fa-save");
            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();
        }
        private void RenderDiscardButton(GridRendererContext rendererContext)
        {
            rendererContext.OpenElement(HtmlTagNames.Button, "action-button");
            rendererContext.AddOnClickEvent(() =>
                                            BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
                                                                             rendererContext.TableDataSet.CancelEditation())
                                            );

            rendererContext.OpenElement(HtmlTagNames.Span, "action-button-span");
            rendererContext.OpenElement(HtmlTagNames.I, "fas fa-times");
            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();
        }
Exemplo n.º 13
0
        private void RenderButton(GridRendererContext rendererContext, PaginationButtonType buttonType, bool disabled, string buttonArrowClass)
        {
            rendererContext.OpenElement(HtmlTagNames.Button, !disabled ? "pagination-button" : "pagination-button pagination-button-disabled");
            rendererContext.AddDisabled(disabled);
            rendererContext.AddOnClickEvent(() =>
                                            BindMethods.GetEventHandlerValue(async(UIMouseEventArgs e) =>
                                                                             await GetPaginationTask(rendererContext, buttonType))
                                            );

            rendererContext.OpenElement(HtmlTagNames.Span, "pagination-button-arrow");
            rendererContext.OpenElement(HtmlTagNames.I, buttonArrowClass);
            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();
        }
Exemplo n.º 14
0
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            if (!CreateItemOptions.IsCreateItemAllowed ||
                !PermissionContext.HasCreateItemPermission)
            {
                return;
            }

            base.BuildRenderTree(builder);

            var internalBuilder = new BlazorRendererTreeBuilder(builder);

            var createItemContext = new CreateItemContext(CreateItemOptions, CreateFormCssClasses);

            createItemContext.OnItemCreated += (object sender, ItemCreatedArgs e) => NewItemCreated?.Invoke(e);

            internalBuilder
            .OpenElement(HtmlTagNames.Div, "modal")
            .AddAttribute(HtmlAttributes.Id, CreateItemOptions.CreateItemModalName)
            .AddAttribute("role", "dialog")
            .OpenElement(HtmlTagNames.Div, $"modal-dialog modal-dialog-centered {CreateFormCssClasses.ModalSize}")
            .AddAttribute(HtmlAttributes.Id, CreateItemOptions.CreateItemModalSizeDiv)
            .OpenElement(HtmlTagNames.Div, "modal-content")
            .OpenElement(HtmlTagNames.Div, CreateFormCssClasses.ModalHeader)
            .OpenElement(HtmlTagNames.H4, "modal-title")
            .AddContent("Create Item")
            .CloseElement()
            .OpenElement(HtmlTagNames.Button, "close")
            .AddAttribute(HtmlJSEvents.OnClick, BindMethods.GetEventHandlerValue((UIMouseEventArgs e) => FlexGridInterop.HideModal(CreateItemOptions.CreateItemModalName)))
            .AddAttribute(HtmlAttributes.Type, "button")
            .AddAttribute("data-dismiss", "modal")
            .AddAttribute("aria-label", "Close")
            .OpenElement(HtmlTagNames.Span)
            .AddAttribute(HtmlAttributes.AriaHidden, "true")
            .AddContent(new MarkupString("&times;"))
            .CloseElement()
            .CloseElement()
            .CloseElement()
            .OpenElement(HtmlTagNames.Div, CreateFormCssClasses.ModalBody)
            .OpenComponent(typeof(CreateItemForm <,>)
                           .MakeGenericType(CreateItemOptions.ModelType, CreateItemOptions.OutputDtoType))
            .AddAttribute(nameof(CreateItemContext), createItemContext)
            .CloseComponent()
            .CloseElement()
            .CloseElement()
            .CloseElement()
            .CloseElement();
        }
        private void RenderEditButton(GridRendererContext rendererContext)
        {
            var localActualItem = rendererContext.ActualItem;

            rendererContext.OpenElement(HtmlTagNames.Button, "action-button");
            rendererContext.AddOnClickEvent(() =>
                                            BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
                                                                             rendererContext.TableDataSet.StartEditItem(localActualItem))
                                            );

            rendererContext.OpenElement(HtmlTagNames.Span, "action-button-span");
            rendererContext.OpenElement(HtmlTagNames.I, "fas fa-edit");
            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();
        }
        public override void Render(GridRendererContext rendererContext)
        {
            if (!rendererContext.IsFirstColumn || !rendererContext.GridConfiguration.IsMasterTable)
            {
                return;
            }

            var localActualItem = rendererContext.ActualItem;

            rendererContext.OpenElement(HtmlTagNames.TableColumn, rendererContext.CssClasses.TableCell);
            rendererContext.AddOnClickEvent(() => BindMethods.GetEventHandlerValue((UIMouseEventArgs async) =>
            {
                rendererContext.TableDataSet.ToggleRowItem(localActualItem);
            }));

            rendererContext.AddContent(">");
            rendererContext.CloseElement();
        }
Exemplo n.º 17
0
        protected override void RenderInternal(GridRendererContext rendererContext, PermissionContext permissionContext)
        {
            var localActualItem           = rendererContext.ActualItem;
            var localActualItemIsSelected = rendererContext.TableDataSet.ItemIsSelected(localActualItem);

            rendererContext.OpenElement(HtmlTagNames.TableColumn, rendererContext.CssClasses.TableCell);
            rendererContext.AddOnClickEvent(() =>
                                            BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
                                                                             rendererContext.TableDataSet.ToggleRowItem(localActualItem))
                                            );

            rendererContext.AddContent(string.Empty);
            rendererContext.OpenElement(HtmlTagNames.Span, "pagination-button-arrow");
            rendererContext.OpenElement(HtmlTagNames.I, localActualItemIsSelected ? "fas fa-angle-down" : "fas fa-angle-right");
            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();
        }
Exemplo n.º 18
0
        private void BuildCreateItemButtonRendererTree(GridRendererContext rendererContext, PermissionContext permissionContext)
        {
            rendererContext.OpenElement(HtmlTagNames.TableHeadCell, rendererContext.CssClasses.TableHeaderCell);
            rendererContext.OpenElement(HtmlTagNames.Div, "create-button-wrapper");

            rendererContext.OpenElement(HtmlTagNames.Button, "action-button");
            rendererContext.AddOnClickEvent(() =>
                                            BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
                                                                             flexGridInterop.ShowModal(CreateItemOptions.CreateItemModalName))
                                            );

            rendererContext.OpenElement(HtmlTagNames.Span, "action-button-span");
            rendererContext.OpenElement(HtmlTagNames.I, "fas fa-plus");
            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();
        }
Exemplo n.º 19
0
        protected override void BuildRendererTreeInternal(GridRendererContext rendererContext, PermissionContext permissionContext)
        {
            rendererContext.OpenElement(HtmlTagNames.TableColumn, rendererContext.CssClasses.TableCell);


            if (!rendererContext.IsActualItemEdited)
            {
                var localActualItem = rendererContext.ActualItem;

                rendererContext.AddOnClickEvent(
                    () => BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
                {
                    rendererContext.TableDataSet
                    .GridViewEvents
                    .OnItemClicked?.Invoke(new ItemClickedArgs {
                        Item = localActualItem
                    });
                })
                    );
            }

            if (!rendererContext.IsActualItemEdited)
            {
                rendererContext.AddActualColumnValue(permissionContext);
                rendererContext.CloseElement();

                return;
            }

            if (rendererContext.ActualColumnPropertyCanBeEdited && permissionContext.HasCurrentUserWritePermission(rendererContext.ActualColumnName))
            {
                editInputRendererTree.BuildInputRendererTree(
                    rendererContext.RendererTreeBuilder,
                    rendererContext,
                    rendererContext.TableDataSet.EditItemProperty);
            }
            else
            {
                rendererContext.AddActualColumnValue(permissionContext);
            }

            rendererContext.CloseElement();
        }
Exemplo n.º 20
0
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            int seq = -1;

            builder.OpenElement(seq++, "li");
            builder.AddAttribute(seq++, "id", Id);
            builder.AddAttribute(seq++, "onclick", BindMethods.GetEventHandlerValue <UIMouseEventArgs>((e) => OnClickInternal(e)));
            builder.AddAttribute(seq++, "class", "blazor-context-menu__item " + ClassCalc);
            builder.AddAttribute(seq++, "style", Visible ? "display:block;" : "display:none;");
            builder.AddAttribute(seq++, "item-enabled", Enabled.ToString().ToLower());
            builder.AddAttribute(seq++, "onmouseover", Enabled ? $"blazorContextMenu.OnMenuItemMouseOver(event, {SubmenuXOffset ?? BlazorContextMenuDefaults.SubMenuXPositionPixelsOffset}, this);" : "");
            builder.AddAttribute(seq++, "onmouseout", Enabled ? "blazorContextMenu.OnMenuItemMouseOut(event);" : "");

            builder.AddElementReferenceCapture(seq++, (reference) => MenuItemElement = reference);
            builder.AddContent(seq++, ChildContent);
            builder.CloseElement();

            base.BuildRenderTree(builder);
        }
Exemplo n.º 21
0
        private void RenderButton(GridRendererContext rendererContext, PaginationButtonType buttonType, bool disabled, string buttonArrowClass)
        {
            rendererContext.OpenElement(HtmlTagNames.Button, !disabled
                ? rendererContext.CssClasses.FooterCssClasses.PaginationButton
                : rendererContext.CssClasses.FooterCssClasses.PaginationButtonDisabled);
            rendererContext.AddDisabled(disabled);
            rendererContext.AddOnClickEvent(() =>
                                            BindMethods.GetEventHandlerValue(async(UIMouseEventArgs e) =>
            {
                await GetPaginationTask(rendererContext, buttonType);
                rendererContext.RequestRerenderNotification?.Invoke();
            })
                                            );

            rendererContext.OpenElement(HtmlTagNames.Span, "pagination-button-arrow");
            rendererContext.OpenElement(HtmlTagNames.I, buttonArrowClass);
            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();
        }
Exemplo n.º 22
0
        protected override void BuildRendererTreeInternal(GridRendererContext rendererContext, PermissionContext permissionContext)
        {
            if (!permissionContext.HasCreateItemPermission)
            {
                return;
            }

            rendererContext.OpenElement(HtmlTagNames.Div, "modal");
            rendererContext.AddAttribute(HtmlAttributes.Id, CreateItemOptions.CreateItemModalName);
            rendererContext.AddAttribute("role", "dialog");

            rendererContext.OpenElement(HtmlTagNames.Div, "modal-dialog modal-lg modal-dialog-centered");
            rendererContext.OpenElement(HtmlTagNames.Div, "modal-content");

            rendererContext.OpenElement(HtmlTagNames.Div, "modal-header");
            rendererContext.OpenElement(HtmlTagNames.H4, "modal-title");
            rendererContext.AddContent("Create Item");
            rendererContext.CloseElement();
            rendererContext.OpenElement(HtmlTagNames.Button, "close");
            rendererContext.AddOnClickEvent(() =>
                                            BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
                                                                             FlexGridInterop.HideModal(CreateItemOptions.CreateItemModalName)));
            rendererContext.AddAttribute(HtmlAttributes.Type, "button");
            rendererContext.AddAttribute("data-dismiss", "modal");
            rendererContext.AddAttribute("aria-label", "Close");
            rendererContext.OpenElement(HtmlTagNames.Span);
            rendererContext.AddAttribute(HtmlAttributes.AriaHidden, "true");
            rendererContext.AddContent("&times;");
            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();

            rendererContext.OpenElement(HtmlTagNames.Div, "modal-body");
            rendererContext.AddCreateItemComponent();

            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();
        }
        private void RenderButton(GridRendererContext rendererContext, PaginationButtonType buttonType, bool disabled, string buttonArrowClass)
        {
            rendererContext.OpenElement(HtmlTagNames.Button, !disabled ? "pagination-button" : "pagination-button pagination-button-disabled");
            rendererContext.AddDisabled(disabled);

            // This is not good but when click function is passed as parameter every button
            // Have seme on click events
            rendererContext.AddOnClickEvent(() => BindMethods.GetEventHandlerValue((UIMouseEventArgs async) =>
                                                                                   buttonType == PaginationButtonType.Previous
                  ? rendererContext.TableDataSet.GoToPreviousPage()
                  : buttonType == PaginationButtonType.Next
                      ? rendererContext.TableDataSet.GoToNextPage()
                      : buttonType == PaginationButtonType.First
                          ? rendererContext.TableDataSet.GoToFirstPage()
                          : rendererContext.TableDataSet.GoToLastPage()));

            rendererContext.OpenElement(HtmlTagNames.Span, "pagination-button-arrow");
            rendererContext.OpenElement(HtmlTagNames.I, buttonArrowClass);
            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();
        }
        public override void Render(GridRendererContext rendererContext)
        {
            if (!rendererContext.IsFirstColumn || !rendererContext.GridConfiguration.IsMasterTable)
            {
                return;
            }

            var localActualItem           = rendererContext.ActualItem;
            var localActualItemIsSelected = rendererContext.TableDataSet.ItemIsSelected(localActualItem);

            rendererContext.OpenElement(HtmlTagNames.TableColumn, rendererContext.CssClasses.TableCell);
            rendererContext.AddOnClickEvent(() =>
                                            BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
                                                                             rendererContext.TableDataSet.ToggleRowItem(localActualItem))
                                            );

            rendererContext.AddContent(string.Empty);
            rendererContext.OpenElement(HtmlTagNames.Span, "pagination-button-arrow");
            rendererContext.OpenElement(HtmlTagNames.I, localActualItemIsSelected ? "fas fa-angle-down" : "fas fa-angle-right");
            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();
        }
Exemplo n.º 25
0
 protected override void AddAdditionalAttributes(RenderTreeBuilder builder)
 {
     builder.AddAttribute(
         this.RenderCounter++,
         "onmousedown",
         BindMethods.GetEventHandlerValue <UIMouseEventArgs>((e) =>
     {
         this.Element.SendPressed();
     }));
     builder.AddAttribute(
         this.RenderCounter++,
         "onmouseup",
         BindMethods.GetEventHandlerValue <UIMouseEventArgs>((e) =>
     {
         this.Element.SendReleased();
     }));
     builder.AddAttribute(
         this.RenderCounter++,
         "onclick",
         BindMethods.GetEventHandlerValue <UIMouseEventArgs>((e) =>
     {
         this.Element.SendClicked();
     }));
 }
Exemplo n.º 26
0
        private void createPagerItem(RenderTreeBuilder builder, ref int seq, int pageIndex, string text, PagerItemType itemType)
        {
            var containerTag   = PagerItemContainerTagName;
            var containerClass = PagerItemContainerCssClass;
            var itemClass      = PagerItemCssClass;

            switch (itemType)
            {
            case PagerItemType.Number:
                containerTag   = GetFirstNonNullString(new[] { NumericPagerItemContainerTagName, containerTag });
                containerClass = GetFirstNonNullString(new[] { NumericPagerItemContainerCssClass, containerClass });
                itemClass      = GetFirstNonNullString(new[] { NumericPagerItemCssClass, itemClass });
                break;

            case PagerItemType.Navigation:
                containerTag   = GetFirstNonNullString(new[] { NavigationPagerItemContainerTagName, containerTag });
                containerClass = GetFirstNonNullString(new[] { NavigationPagerItemContainerCssClass, containerClass });
                itemClass      = GetFirstNonNullString(new[] { NavigationPagerItemCssClass, itemClass });
                break;

            case PagerItemType.Current:
                containerTag   = GetFirstNonNullString(new[] { CurrentPagerItemContainerTagName, NumericPagerItemContainerTagName, containerTag });
                containerClass = GetFirstNonNullString(new[] { CurrentPagerItemContainerCssClass, NumericPagerItemContainerCssClass, containerClass });
                itemClass      = GetFirstNonNullString(new[] { CurrentPagerItemCssClass, NumericPagerItemCssClass, itemClass });
                break;

            case PagerItemType.More:
                containerTag   = GetFirstNonNullString(new[] { MorePagerItemContainerTagName, containerTag });
                containerClass = GetFirstNonNullString(new[] { MorePagerItemContainerCssClass, containerClass });
                itemClass      = GetFirstNonNullString(new[] { MorePagerItemCssClass, itemClass });
                break;

            case PagerItemType.Disabled:
                containerTag   = GetFirstNonNullString(new[] { DisabledPagerItemContainerTagName, NavigationPagerItemContainerTagName, containerTag });
                containerClass = GetFirstNonNullString(new[] { DisabledPagerItemContainerCssClass, NavigationPagerItemContainerCssClass, containerClass });
                itemClass      = GetFirstNonNullString(new[] { DisabledPagerItemCssClass, NavigationPagerItemCssClass, itemClass });
                break;
            }
            bool hasContainerTag = !string.IsNullOrWhiteSpace(containerTag);

            if (hasContainerTag)
            {
                builder.OpenElement(++seq, containerTag);
                if (!string.IsNullOrWhiteSpace(containerClass))
                {
                    builder.AddAttribute(++seq, "class", containerClass);
                }
            }
            builder.OpenElement(++seq, "a");
            if (!string.IsNullOrWhiteSpace(itemClass))
            {
                builder.AddAttribute(++seq, "class", itemClass);
            }
            if (pageIndex > 0)
            {
                builder.AddAttribute(++seq, "href", string.Format(RoutePattern, pageIndex));
                builder.AddAttribute(++seq, "onclick", BindMethods.GetEventHandlerValue <UIMouseEventArgs>(() => ChangePage(pageIndex)));
            }
            var pagerItemText = text;

            if (itemType == PagerItemType.Number || itemType == PagerItemType.Current)
            {
                var numberFormat = string.IsNullOrWhiteSpace(NumericPagerItemTextFormatString) ? "{0}" : NumericPagerItemTextFormatString;
                if (itemType == PagerItemType.Current && !string.IsNullOrWhiteSpace((CurrentPagerItemTextFormatString)))
                {
                    numberFormat = CurrentPagerItemTextFormatString;
                }
                pagerItemText = string.Format(numberFormat, text);
            }
            builder.AddMarkupContent(++seq, pagerItemText);
            builder.CloseElement();
            if (hasContainerTag)
            {
                builder.CloseElement();
            }
        }
Exemplo n.º 27
0
        protected override void BuildRenderTreeInternal(GridRendererContext rendererContext, PermissionContext permissionContext)
        {
            var  actualGroupItem = (GroupItem)rendererContext.ActualItem;
            bool isCollapsed     = actualGroupItem.IsCollapsed;

            rendererContext.OpenElement(HtmlTagNames.TableBody, isCollapsed? "table-group-row-wrapper-collapsed" : "table-group-row-wrapper");
            try
            {
                rendererContext.OpenElement(HtmlTagNames.TableRow, rendererContext.CssClasses.TableGroupRow);
                rendererContext.OpenElement(HtmlTagNames.TableColumn, rendererContext.CssClasses.TableGroupRowCell);

                int numberOfColumns = rendererContext.GridItemProperties.Count;
                if (rendererContext.GridConfiguration.InlineEditOptions.InlineEditIsAllowed)
                {
                    numberOfColumns++;
                }
                if (rendererContext.GridConfiguration.IsMasterTable)
                {
                    numberOfColumns++;
                }
                rendererContext.AddAttribute(HtmlAttributes.Colspan, numberOfColumns);

                rendererContext.AddOnClickEvent(() =>
                                                BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
                {
                    rendererContext.TableDataSet.ToggleGroupRow(actualGroupItem.Key);
                    rendererContext.RequestRerenderNotification?.Invoke();
                })
                                                );

                rendererContext.OpenElement(HtmlTagNames.I, !isCollapsed ? "fas fa-angle-down" : "fas fa-angle-right");
                rendererContext.CloseElement();

                var keyProperty = rendererContext.ActualItem.GetType().GetProperty("Key");
                var keyValue    = keyProperty != null?keyProperty.GetValue(rendererContext.ActualItem) : null;

                var key = keyValue != null?keyValue.ToString() : "(null)";

                if (string.IsNullOrEmpty(key))
                {
                    key = @"""";
                }
                rendererContext.AddContent($"     {key}   ");

                rendererContext.OpenElement(HtmlTagNames.I);
                rendererContext.AddContent($"({actualGroupItem.Count})");
                rendererContext.CloseElement();

                rendererContext.CloseElement();
                rendererContext.CloseElement();

                var subItems = (IEnumerable)(GroupItem)rendererContext.ActualItem;
                foreach (var item in subItems)
                {
                    rendererContext.ActualItem = item;
                    gridPartRenderers.ForEach(renderer => renderer.BuildRendererTree(rendererContext, permissionContext));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            rendererContext.CloseElement();
        }