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); }