internal virtual void OnCreateContent(TagBuilder tag) { }
public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null) { if (SkipRender(context)) { return; } var dataGrid = new TagBuilder("data-grid", null, IsInGrid); onRender?.Invoke(dataGrid); MergeBindingAttributeBool(dataGrid, context, ":compact", nameof(Compact), Compact); MergeAttributes(dataGrid, context, MergeAttrMode.Margin | MergeAttrMode.Visibility); dataGrid.MergeAttribute("key", Guid.NewGuid().ToString()); // disable vue reusing if (Height != null) { dataGrid.MergeStyle("height", Height.Value); } if (FixedHeader) { dataGrid.MergeAttribute(":fixed-header", "true"); } if (HeadersVisibility == HeadersVisibility.None) { dataGrid.MergeAttribute(":hide-header", "true"); } if (Style != DataGridStyle.Default) { dataGrid.AddCssClass($"data-grid-{Style.ToString().ToKebabCase()}"); } if (RowDetails != null) { dataGrid.MergeAttribute(":row-details", "true"); dataGrid.MergeAttribute("row-details-activate", RowDetails.Activate.ToString().ToLowerInvariant()); var vBind = RowDetails.GetBinding("Visible"); if (vBind != null) { dataGrid.MergeAttribute("row-details-visible", vBind.Path /*!without context!*/); } } var isb = GetBinding(nameof(ItemsSource)); if (isb != null) { dataGrid.MergeAttribute(":items-source", isb.GetPath(context)); } MergeBoolAttribute(dataGrid, context, nameof(Hover), Hover); MergeBoolAttribute(dataGrid, context, nameof(Striped), Striped); MergeBoolAttribute(dataGrid, context, nameof(Border), Border); MergeBoolAttribute(dataGrid, context, nameof(Sort), Sort); dataGrid.MergeAttribute(":route-query", "$query"); // always! if (!String.IsNullOrEmpty(EmptyPanelDelegate)) { dataGrid.MergeAttribute(":empty-panel-callback", $"$delegate('{EmptyPanelDelegate}')"); } var dblClickBind = GetBindingCommand(nameof(DoubleClick)); if (dblClickBind != null) { // Function! dataGrid.MergeAttribute(":doubleclick", "() => " + dblClickBind.GetCommand(context)); } if (MarkerStyle != RowMarkerStyle.None) { dataGrid.MergeAttribute("mark-style", MarkerStyle.ToString().ToKebabCase()); } var mbind = GetBinding(nameof(Mark)); if (mbind != null) { dataGrid.MergeAttribute("mark", mbind.Path); // without context!!! } else if (Mark != MarkStyle.Default) { throw new XamlException("The Mark property must be a binding"); } var rbbind = GetBinding(nameof(RowBold)); if (rbbind != null) { dataGrid.MergeAttribute("row-bold", rbbind.GetPath(context)); } else if (RowBold != null) { throw new XamlException("The RowBold property must be a binding"); } // TODO: binding for GridLines ??? if (GridLines != GridLinesVisibility.None) { dataGrid.MergeAttribute("grid", GridLines.ToString()); } var groupByBind = GetBinding(nameof(GroupBy)); if (groupByBind != null) { dataGrid.MergeAttribute(":group-by", groupByBind.GetPath(context)); } else if (_groupBy != null) { dataGrid.MergeAttribute(":group-by", _groupBy.GetJsValue(context)); } dataGrid.RenderStart(context); Int32 colIndex = 0; foreach (var col in Columns) { col.RenderColumn(context, colIndex); colIndex++; } RenderRowDetails(context); RenderEmptyPanel(context); RenderFooter(context); dataGrid.RenderEnd(context); }
public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null) { /* TODO: * 1. Horizontal splitter */ if (SkipRender(context)) { return; } var spl = new TagBuilder("div", "splitter"); onRender?.Invoke(spl); spl.MergeAttribute("key", Guid.NewGuid().ToString()); // disable vue reusing MergeAttributes(spl, context); if (Height != null) { spl.MergeStyle("height", Height.Value); } if (MinWidth != null) { spl.MergeStyle("min-width", MinWidth.Value); } spl.AddCssClass(Orientation.ToString().ToLowerInvariant()); // width GridLength p1w = GetWidth(Children[0]) ?? GridLength.Fr1(); GridLength p2w = GetWidth(Children[1]) ?? GridLength.Fr1(); String rowsCols = Orientation == Orientation.Vertical ? "grid-template-columns" : "grid-template-rows"; spl.MergeStyle(rowsCols, $"{p1w} 5px {p2w}"); spl.RenderStart(context); // first part var p1 = new TagBuilder("div", "spl-part spl-first"); p1.RenderStart(context); Children[0].RenderElement(context); p1.RenderEnd(context); new TagBuilder("div", "spl-handle") .MergeAttribute(Orientation == Orientation.Vertical ? "v-resize" : "h-resize", String.Empty) //.MergeAttribute("key", Guid.NewGuid().ToString()) // disable vue reusing .MergeAttribute("first-pane-width", p1w?.Value.ToString()) .MergeAttribute("data-min-width", GetMinWidth(Children[0])?.Value.ToString()) .MergeAttribute("second-min-width", GetMinWidth(Children[1])?.Value.ToString()) .Render(context); // second part var p2 = new TagBuilder("div", "spl-part spl-second"); p2.RenderStart(context); Children[1].RenderElement(context); p2.RenderEnd(context); // drag-handle new TagBuilder("div", "drag-handle") .Render(context); spl.RenderEnd(context); }