public static NsPanel ToKendoWidget(this Panel panel, HtmlHelper helper, IJavaScriptInitializer initializer, Kendo.Mvc.IUrlGenerator urlGenerator) { var p = new NsPanel(panel, helper, initializer, urlGenerator); return(p); }
public static Kendo.Mvc.UI.WidgetBase ToKendoWidget(this Tabs tabs, HtmlHelper helper, IJavaScriptInitializer initializer, Kendo.Mvc.IUrlGenerator urlGenerator) { var tabsBuilder = helper.Kendo().TabStrip().Name(tabs.Name); var selected = true; foreach (var tab in tabs.Items) { var control = tab.Panel.ToKendoWidget(helper, initializer, urlGenerator); var html = control.ToHtmlString(); tabsBuilder.Items(a => { a.Add().Text(tab.Name).Content(html).Selected(selected); }); selected = false; } var tabsControl = tabsBuilder.ToComponent(); return(tabsControl); }
public static Kendo.Mvc.UI.WidgetBase ToKendoWidget(this WidgetBase widget, HtmlHelper helper, IJavaScriptInitializer initializer, Kendo.Mvc.IUrlGenerator urlGenerator) { var type = widget.GetType(); if (type.IsGenericType) { if (type.GetGenericTypeDefinition() == typeof(TextBox <>)) { var tb = TextBoxExtensions.CreateTextBox( type.GenericTypeArguments[0], helper, initializer); tb.Name = widget.Name; tb.SetPropValue("Value", widget.GetPropValue("Value")); dynamic dynamicTb = tb; dynamicTb.Enabled = !widget.IsReadOnly; return(tb); } if (type.GetGenericTypeDefinition() == typeof(Grid <>)) { var grid = widget as Grid; var controlType = typeof(Kendo.Mvc.UI.Grid <>).MakeGenericType(type.GenericTypeArguments[0]); var control = (Kendo.Mvc.UI.WidgetBase)Activator.CreateInstance(controlType, new object[] { helper.ViewContext, initializer, urlGenerator, DI.Current.Resolve <Kendo.Mvc.UI.Html.IGridHtmlBuilderFactory>() }); control.Name = "grid"; var gridControl = (Kendo.Mvc.UI.IGrid)control; grid.DataSource.SetDataSource(gridControl.DataSource, helper, initializer, urlGenerator); return(control); } } else { if (widget is Grid) { var grid = widget as Grid; return(grid.ToKendoWidget(helper, initializer)); } if (widget is DatePicker) { var dp = widget as DatePicker; return(dp.ToKendoWidget(helper, initializer)); } if (widget is CheckBox) { var cb = widget as CheckBox; return(cb.ToKendoWidget(helper, initializer)); } if (widget is ComboBox) { var cb = widget as ComboBox; return(cb.ToKendoWidget(helper, initializer, urlGenerator)); } if (widget is Label) { var label = widget as Label; return(label.ToKendoWidget(helper, initializer)); } if (widget is Link) { var link = widget as Link; return(link.ToKendoWidget(helper, initializer)); } if (widget is Tabs) { var tabs = widget as Tabs; return(tabs.ToKendoWidget(helper, initializer, urlGenerator)); } } if (widget is Panel) { return(new NsPanel(widget as Panel, helper, initializer, urlGenerator)); } return(null); }