public IDictionary <string, object> SeriailzeBaseOptions() { var options = new Dictionary <string, object>(Events); var idPrefix = "#"; if (IsInClientTemplate) { idPrefix = "\\" + idPrefix; } if (!string.IsNullOrEmpty(DataSource.Transport.Read.Url)) { options["dataSource"] = DataSource.ToJson(); } else if (DataSource.Data != null) { options["dataSource"] = DataSource.Data; } var animation = Animation.ToJson(); if (animation.Keys.Any()) { options["animation"] = animation["animation"]; } if (!string.IsNullOrEmpty(DataTextField)) { options["dataTextField"] = DataTextField; } if (Delay != null) { options["delay"] = Delay; } if (IgnoreCase != null) { options["ignoreCase"] = IgnoreCase; } if (Height != null) { options["height"] = Height; } if (!string.IsNullOrEmpty(TemplateId)) { options["template"] = new ClientHandlerDescriptor { HandlerName = string.Format("$('{0}{1}').html()", idPrefix, TemplateId) }; } else if (!string.IsNullOrEmpty(Template)) { options["template"] = Template; } return(options); }
protected override void Serialize(IDictionary <string, object> json) { if (!string.IsNullOrEmpty(DataSource.Transport.Read.Url)) { json["dataSource"] = DataSource.ToJson(); } else if (DataSource.Data != null) { json["dataSource"] = DataSource.Data; } if (!string.IsNullOrEmpty(Title)) { json["title"] = Title; } json["field"] = Field; if (Multiple != false) { json["multiple"] = Multiple; } if (!string.IsNullOrEmpty(DataTextField)) { json["dataTextField"] = DataTextField; } if (!string.IsNullOrEmpty(DataValueField)) { json["dataValueField"] = DataValueField; } if (!string.IsNullOrEmpty(DataColorField)) { json["dataColorField"] = DataColorField; } if (ValuePrimitive != true) { json["valuePrimitive"] = ValuePrimitive; } if (Name.HasValue()) { json["name"] = Name; } }
private void SerializeDataSource(IDictionary <string, object> options) { if (!string.IsNullOrEmpty(DataSource.Transport.Read.Url)) { if (!DataSource.Transport.Read.Type.HasValue()) { DataSource.Transport.Read.Type = "POST"; } options.Add("dataSource", DataSource.ToJson()); } else if (Data != null) { IDictionary <string, object> result = DataSource.ToJson(); result["data"] = Data; result.Remove("transport"); options.Add("dataSource", result); } }
protected virtual IDictionary <string, object> SeriailzeBaseOptions() { var options = new Dictionary <string, object>(Events); if (!string.IsNullOrEmpty(DataSource.Transport.Read.Url)) { options["dataSource"] = DataSource.ToJson(); } else if (DataSource.Data != null) { options["dataSource"] = DataSource.Data; } var animation = Animation.ToJson(); if (animation.Keys.Any()) { options["animation"] = animation["animation"]; } if (!string.IsNullOrEmpty(DataTextField)) { options["dataTextField"] = DataTextField; } if (Delay != null) { options["delay"] = Delay; } if (IgnoreCase != null) { options["ignoreCase"] = IgnoreCase; } if (Height != null) { options["height"] = Height; } return(options); }
protected virtual void SerializeDataSource(IDictionary <string, object> options) { if (DataSource.Type == DataSourceType.Custom) { DataSource.Data = Data; if (DataSource.CustomType == "aspnetmvc-ajax" && DataSource.Data != null) { ProcessDataSource(); } IDictionary <string, object> result = DataSource.ToJson(); options.Add("dataSource", result); } else if (!string.IsNullOrEmpty(DataSource.Transport.Read.Url)) { if (!DataSource.Transport.Read.Type.HasValue()) { DataSource.Transport.Read.Type = "POST"; } if (DataSource.Type == null) { DataSource.Type = DataSourceType.Ajax; } options.Add("dataSource", DataSource.ToJson()); } else if (Data != null) { IDictionary <string, object> result = DataSource.ToJson(); result["data"] = Data; result.Remove("transport"); options.Add("dataSource", result); } }
public override void WriteInitializationScript(TextWriter writer) { var options = new Dictionary <string, object>(Events); if (!string.IsNullOrEmpty(DataSource.Transport.Read.Url)) { options["dataSource"] = DataSource.ToJson(); } else if (DataSource.Data != null) { options["dataSource"] = DataSource.Data; } if (DragAndDrop) { options["dragAndDrop"] = true; } if (AutoBind) { options["autoBind"] = true; } if (!LoadOnDemand) { options["loadOnDemand"] = false; } if (!string.IsNullOrEmpty(DataTextField)) { options["dataTextField"] = DataTextField; } if (!string.IsNullOrEmpty(DataUrlField)) { options["dataUrlField"] = DataUrlField; } if (!string.IsNullOrEmpty(DataSpriteCssClassField)) { options["dataSpriteCssClassField"] = DataSpriteCssClassField; } if (!string.IsNullOrEmpty(DataImageUrlField)) { options["dataImageUrlField"] = DataImageUrlField; } var idPrefix = "#"; if (IsInClientTemplate) { idPrefix = "\\" + idPrefix; } if (!string.IsNullOrEmpty(TemplateId)) { options["template"] = new ClientHandlerDescriptor { HandlerName = string.Format("$('{0}{1}').html()", idPrefix, TemplateId) }; } else if (!string.IsNullOrEmpty(Template)) { options["template"] = Template; } var checkboxes = Checkboxes.ToJson(); if (checkboxes.Keys.Any()) { options["checkboxes"] = checkboxes["checkboxes"]; } var animation = Animation.ToJson(); if (animation.Keys.Any()) { options["animation"] = animation["animation"]; } writer.Write(Initializer.Initialize(Selector, "TreeView", options)); base.WriteInitializationScript(writer); }
protected virtual IDictionary <string, object> SeriailzeBaseOptions() { var options = new Dictionary <string, object>(Events); var idPrefix = "#"; if (Date != null) { options["date"] = Date; } if (StartTime != null) { options["startTime"] = StartTime; } if (EndTime != null) { options["endTime"] = EndTime; } if (Min != null) { options["min"] = Min; } if (Max != null) { options["max"] = Max; } if (WorkDayStart != null) { options["workDayStart"] = WorkDayStart; } if (WorkDayEnd != null) { options["workDayEnd"] = WorkDayEnd; } if (Height != null) { options["height"] = Height; } if (Editable.Enabled == false) { options["editable"] = false; } else { Editable.InitializeEditor(ViewContext, ViewData); IDictionary <string, object> editable = Editable.ToJson(); if (editable.Count > 0) { options["editable"] = editable; } } if (!string.IsNullOrEmpty(EventTemplate)) { options["eventTemplate"] = EventTemplate; } if (!string.IsNullOrEmpty(EventTemplateId)) { options["eventTemplate"] = new ClientHandlerDescriptor { HandlerName = String.Format("kendo.template($('{0}{1}').html())", idPrefix, EventTemplateId) }; } if (!string.IsNullOrEmpty(AllDayEventTemplate)) { options["allDayEventTemplate"] = AllDayEventTemplate; } if (!string.IsNullOrEmpty(AllDayEventTemplateId)) { options["allDayEventTemplate"] = new ClientHandlerDescriptor { HandlerName = String.Format("kendo.template($('{0}{1}').html())", idPrefix, AllDayEventTemplateId) }; } if (!AllDaySlot) { options["allDaySlot"] = AllDaySlot; } if (Selectable) { options["selectable"] = Selectable; } if (!string.IsNullOrEmpty(DateHeaderTemplate)) { options["dateHeaderTemplate"] = DateHeaderTemplate; } if (!string.IsNullOrEmpty(DateHeaderTemplateId)) { options["dateHeaderTemplate"] = new ClientHandlerDescriptor { HandlerName = String.Format("kendo.template($('{0}{1}').html())", idPrefix, DateHeaderTemplateId) }; } if (MajorTick != null) { options["majorTick"] = MajorTick; } if (ShowWorkHours) { options["showWorkHours"] = ShowWorkHours; } if (!string.IsNullOrEmpty(MajorTimeHeaderTemplate)) { options["majorTimeHeaderTemplate"] = MajorTimeHeaderTemplate; } if (!string.IsNullOrEmpty(MajorTimeHeaderTemplateId)) { options["majorTimeHeaderTemplate"] = new ClientHandlerDescriptor { HandlerName = String.Format("kendo.template($('{0}{1}').html())", idPrefix, MajorTimeHeaderTemplateId) }; } if (!string.IsNullOrEmpty(MinorTimeHeaderTemplate)) { options["minorTimeHeaderTemplate"] = MinorTimeHeaderTemplate; } if (!string.IsNullOrEmpty(MinorTimeHeaderTemplateId)) { options["minorTimeHeaderTemplate"] = new ClientHandlerDescriptor { HandlerName = String.Format("kendo.template($('{0}{1}').html())", idPrefix, MinorTimeHeaderTemplateId) }; } if (MinorTickCount != null) { options["minorTickCount"] = MinorTickCount; } if (!string.IsNullOrEmpty(Timezone)) { options["timezone"] = Timezone; } if (Width != null) { options["width"] = Width; } if (!Snap) { options["snap"] = Snap; } if (!AutoBind) { options["autoBind"] = AutoBind; } if (WorkWeekStart != null) { options["workWeekStart"] = WorkWeekStart; } if (WorkWeekEnd != null) { options["workWeekEnd"] = WorkWeekEnd; } if (Resources.Count > 0) { options["resources"] = Resources.ToJson(); } if (Views.Count > 0) { options["views"] = Views.ToJson(); } var messages = Messages.ToJson(); if (messages.Count > 0) { options["messages"] = messages; } var group = Group.ToJson(); if (group.Count > 0) { options["group"] = group; } if (Mobile != MobileMode.Disabled) { if (Mobile == MobileMode.Auto) { options["mobile"] = true; } else { options["mobile"] = Mobile.ToString().ToLowerInvariant(); } } if (DataSource.Type != DataSourceType.Custom || DataSource.CustomType == "aspnetmvc-ajax") { DataSource.Transport.StringifyDates = true; if (DataSource.IsClientOperationMode) { ProcessDataSource(); } } Dictionary <string, object> dataSource = (Dictionary <string, object>)DataSource.ToJson(); options["dataSource"] = dataSource; return(options); }
public override void WriteInitializationScript(TextWriter writer) { var options = new Dictionary <string, object>(Events); var autoBind = DataSource.Type != DataSourceType.Server && AutoBind.GetValueOrDefault(true); var columns = VisibleColumns.Select(c => c.ToJson()); var idPrefix = "#"; if (IsInClientTemplate) { idPrefix = "\\" + idPrefix; } if (columns.Any()) { options["columns"] = columns; } if (Grouping.Enabled) { options["groupable"] = Grouping.ToJson(); } if (Pageable.Enabled) { Pageable.AutoBind = autoBind; options["pageable"] = Pageable.ToJson(); } if (Sortable.Enabled) { var sorting = Sortable.ToJson(); options["sortable"] = sorting.Any() ? (object)sorting : true; } if (Selectable.Enabled) { options["selectable"] = String.Format("{0}, {1}", Selectable.Mode, Selectable.Type); } if (Filterable.Enabled) { var filtering = Filterable.ToJson(); options["filterable"] = filtering.Any() ? (object)filtering : true; } if (ColumnMenu.Enabled) { var menu = ColumnMenu.ToJson(); options["columnMenu"] = menu.Any() ? (object)menu : true; } if (Resizable.Enabled) { options["resizable"] = true; } if (ColumnResizeHandleWidth != defaultColumnResizeHandleWidth) { options["columnResizeHandleWidth"] = ColumnResizeHandleWidth; } if (Reorderable.Enabled) { options["reorderable"] = true; } if (!Scrollable.Enabled) { options["scrollable"] = false; } else { var scrolling = Scrollable.ToJson(); if (scrolling.Any()) { options["scrollable"] = scrolling; } } if (Editable.Enabled) { options["editable"] = Editable.ToJson(); } if (ToolBar.Enabled) { options["toolbar"] = ToolBar.ToJson(); } if (autoBind == false) { options["autoBind"] = autoBind; } options["dataSource"] = DataSource.ToJson(); if (!String.IsNullOrEmpty(ClientDetailTemplateId)) { options["detailTemplate"] = new ClientHandlerDescriptor { HandlerName = String.Format("kendo.template($('{0}{1}').html())", idPrefix, ClientDetailTemplateId) }; } if (!String.IsNullOrEmpty(ClientRowTemplate)) { options["rowTemplate"] = ClientRowTemplate; } if (!String.IsNullOrEmpty(ClientAltRowTemplate)) { options["altRowTemplate"] = ClientAltRowTemplate; } if (Navigatable.Enabled) { options["navigatable"] = true; } if (Mobile != MobileMode.Disabled) { if (Mobile == MobileMode.Auto) { options["mobile"] = true; } else { options["mobile"] = Mobile.ToString().ToLowerInvariant(); } } writer.Write(Initializer.Initialize(Selector, "Grid", options)); base.WriteInitializationScript(writer); }
protected override void Serialize(IDictionary <string, object> json) { var dataSource = DataSource.ToJson(); if (dataSource.Any()) { json["dataSource"] = dataSource; } if (Subdomains != null) { json["subdomains"] = Subdomains; } //>> Serialization if (Attribution.HasValue()) { json["attribution"] = Attribution; } if (AutoBind.HasValue) { json["autoBind"] = AutoBind; } if (Extent != null) { json["extent"] = Extent; } if (Key.HasValue()) { json["key"] = Key; } if (LocationField.HasValue()) { json["locationField"] = LocationField; } if (TitleField.HasValue()) { json["titleField"] = TitleField; } if (Opacity.HasValue()) { json["opacity"] = Opacity; } var style = Style.ToJson(); if (style.Any()) { json["style"] = style; } if (UrlTemplateId.HasValue()) { json["urlTemplate"] = UrlTemplateId; } if (Type.HasValue) { json["type"] = Type; } //<< Serialization var tooltip = Tooltip.ToJson(); if (tooltip.Any()) { json["tooltip"] = tooltip; } if (ShapeName.HasValue()) { json["shape"] = ShapeName; } else if (Shape.HasValue) { var shapeName = Shape.ToString(); json["shape"] = shapeName.ToLowerInvariant()[0] + shapeName.Substring(1); } }
//<< Fields public override void WriteInitializationScript(TextWriter writer) { var json = new Dictionary <string, object>(Events); if (!string.IsNullOrEmpty(DataSource.Transport.Read.Url) || DataSource.Type == DataSourceType.Custom) { json["dataSource"] = DataSource.ToJson(); } else if (DataSource.Data != null) { json["dataSource"] = DataSource.Data; } //>> Serialization if (AutoBind.HasValue) { json["autoBind"] = AutoBind; } if (ZoomRate.HasValue) { json["zoomRate"] = ZoomRate; } if (Draggable.HasValue) { json["draggable"] = Draggable; } var layout = Layout.ToJson(); if (layout.Any()) { json["layout"] = layout; } if (TemplateId.HasValue()) { json["template"] = TemplateId; } if (Resizable.HasValue) { json["resizable"] = Resizable; } if (Rotatable.HasValue) { json["rotatable"] = Rotatable; } var connectionDefaults = ConnectionDefaults.ToJson(); if (connectionDefaults.Any()) { json["connectionDefaults"] = connectionDefaults; } var connections = Connections.ToJson(); if (connections.Any()) { json["connections"] = connections; } var shapeDefaults = ShapeDefaults.ToJson(); if (shapeDefaults.Any()) { json["shapeDefaults"] = shapeDefaults; } var shapes = Shapes.ToJson(); if (shapes.Any()) { json["shapes"] = shapes; } //<< Serialization writer.Write(Initializer.Initialize(Selector, "Diagram", json)); base.WriteInitializationScript(writer); }