public void SerializeTo(string key, IClientSideObjectWriter writer)
 {
     if (Enabled)
     {
         writer.Append("selectable", true);
     }
 }
Exemplo n.º 2
0
        private void SerializeAxes <TAxis>(string key, IList <TAxis> axes, IClientSideObjectWriter objectWriter)
            where TAxis : IChartAxis
        {
            if (axes.Count > 0)
            {
                var serializedAxes  = new List <IDictionary <string, object> >();
                var shouldSerialize = false;

                for (var i = 0; i < axes.Count; i++)
                {
                    var a         = axes[i];
                    var data      = a.CreateSerializer().Serialize();
                    var isPrimary = i == 0 && axes.Count > 1;

                    if (data.Count > 0 || isPrimary)
                    {
                        serializedAxes.Add(data);
                        shouldSerialize = true;
                    }
                }

                if (shouldSerialize)
                {
                    objectWriter.AppendCollection(key, serializedAxes);
                }
            }
        }
Exemplo n.º 3
0
        public override void WriteInitializationScript(TextWriter writer)
        {
            IClientSideObjectWriter objectWriter = ClientSideObjectWriterFactory.Create(Id, "tDatePicker", writer);

            objectWriter.Start();

            if (!defaultEffects.SequenceEqual(Effects.Container))
            {
                objectWriter.Serialize("effects", Effects);
            }

            ClientEvents.SerializeTo(objectWriter);

            objectWriter.Append("format", this.Format);
            objectWriter.Append("todayFormat", TodayFormat);
            objectWriter.AppendDateOnly("minValue", this.MinValue);
            objectWriter.AppendDateOnly("maxValue", this.MaxValue);
            objectWriter.AppendDateOnly("selectedValue", this.Value);
            objectWriter.Append("enabled", this.Enabled, true);
            objectWriter.Append("openOnFocus", this.OpenOnFocus, false);

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }
        public void SerializeTo(string key, IClientSideObjectWriter writer)
        {
            if (Enabled)
            {
                Func<string,string> encoder = (string url) => grid.IsSelfInitialized ? HttpUtility.UrlDecode(url) : url;

                var urlBuilder = new GridUrlBuilder(grid);

                var urls = new Dictionary<string, string>();

                urls["selectUrl"] = encoder(urlBuilder.Url(Select));

                if (Insert.HasValue())
                {
                    urls["insertUrl"] = encoder(urlBuilder.Url(Insert));
                }

                if (Update.HasValue())
                {
                    urls["updateUrl"] = encoder(urlBuilder.Url(Update));
                }

                if (Delete.HasValue())
                {
                    urls["deleteUrl"] = encoder(urlBuilder.Url(Delete));
                }

                writer.AppendObject(key, urls);
            }
        }
Exemplo n.º 5
0
        public override void WriteInitializationScript(System.IO.TextWriter writer)
        {
            IClientSideObjectWriter objectWriter = ClientSideObjectWriterFactory.Create(Id, "tDateTimePicker", writer);

            objectWriter.Start();

            if (!defaultEffects.SequenceEqual(Effects.Container))
            {
                objectWriter.Serialize("effects", Effects);
            }

            ClientEvents.SerializeTo(objectWriter);

            objectWriter.Append("format", this.Format);
            objectWriter.Append("minValue", this.MinValue);
            objectWriter.Append("maxValue", this.MaxValue);
            objectWriter.Append("startTimeValue", this.StartTime);
            objectWriter.Append("endTimeValue", this.EndTime);
            objectWriter.Append("interval", this.Interval);
            objectWriter.Append("selectedValue", this.Value);
            objectWriter.Append("enabled", this.Enabled, true);

            if (DropDownHtmlAttributes.Any())
            {
                objectWriter.Append("dropDownAttr", DropDownHtmlAttributes.ToAttributeString());
            }

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }
        public void SerializeTo(string key, IClientSideObjectWriter writer)
        {
            if (Enabled)
            {
                var urlBuilder = grid.UrlBuilder;

                var urls = new Dictionary<string, string>();

                if (Select.HasValue() || (SerializeEmptySelectUrl && !Select.HasValue()))
                {
                    urls["selectUrl"] = Encode(urlBuilder.Url(Select));
                }

                if (Insert.HasValue())
                {
                    urls["insertUrl"] = Encode(urlBuilder.Url(Insert));
                }

                if (Update.HasValue())
                {
                    urls["updateUrl"] = Encode(urlBuilder.Url(Update));
                }

                if (Delete.HasValue())
                {
                    urls["deleteUrl"] = Encode(urlBuilder.Url(Delete));
                }

                writer.AppendObject(key, urls);
            }
        }
Exemplo n.º 7
0
        public static Grid <T> CreateGrid <T>(HtmlTextWriter writer, IClientSideObjectWriter objectWriter) where T : class
        {
            Mock <HttpContextBase> httpContext = TestHelper.CreateMockedHttpContext();

            if (writer != null)
            {
                httpContext.Setup(c => c.Request.Browser.CreateHtmlTextWriter(It.IsAny <TextWriter>())).Returns(writer);
            }

            Mock <IViewDataContainer> viewDataContainer = new Mock <IViewDataContainer>();
            Mock <IUrlGenerator>      urlGenerator      = new Mock <IUrlGenerator>();

            viewDataContainer.SetupGet(container => container.ViewData).Returns(new ViewDataDictionary());

            ViewContext viewContext = TestHelper.CreateViewContext();

            Mock <IClientSideObjectWriterFactory> clientSideObjectFactory = new Mock <IClientSideObjectWriterFactory>();

            clientSideObjectFactory.Setup(f => f.Create(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <TextWriter>())).Returns(objectWriter);

            var htmlBuilderFactory = new Mock <IGridHtmlBuilderFactory>();

            Grid <T> grid = new Grid <T>(viewContext, clientSideObjectFactory.Object, urlGenerator.Object, CreateLocalizationService(), htmlBuilderFactory.Object)
            {
                Name = "Grid"
            };

            return(grid);
        }
Exemplo n.º 8
0
        public override void WriteInitializationScript(TextWriter writer)
        {
            IClientSideObjectWriter objectWriter = ClientSideObjectWriterFactory.Create(Id, "tMenu", writer);

            objectWriter.Start()
            .Append("orientation", Orientation, MenuOrientation.Horizontal);

            if (!defaultEffects.SequenceEqual(Effects.Container))
            {
                objectWriter.Serialize("effects", Effects);
            }

            if (OpenOnClick)
            {
                objectWriter.Append("openOnClick", true);
            }

            objectWriter.AppendClientEvent("onOpen", ClientEvents.OnOpen);
            objectWriter.AppendClientEvent("onClose", ClientEvents.OnClose);
            objectWriter.AppendClientEvent("onSelect", ClientEvents.OnSelect);
            objectWriter.AppendClientEvent("onLoad", ClientEvents.OnLoad);

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }
Exemplo n.º 9
0
        public override void WriteInitializationScript(System.IO.TextWriter writer)
        {
            IClientSideObjectWriter objectWriter = ClientSideObjectWriterFactory.Create(Id, "tTextBox", writer);

            objectWriter.Start();

            objectWriter.AppendObject("val", this.Value);
            objectWriter.AppendObject("step", this.IncrementStep);
            objectWriter.AppendObject("minValue", this.MinValue);
            objectWriter.AppendObject("maxValue", this.MaxValue);
            objectWriter.Append("digits", this.DecimalDigits);
            objectWriter.Append("separator", this.DecimalSeparator);
            objectWriter.AppendNullableString("groupSeparator", this.NumberGroupSeparator);
            objectWriter.Append("groupSize", this.NumberGroupSize);
            objectWriter.Append("negative", this.NegativePatternIndex);
            objectWriter.Append("text", this.EmptyMessage);
            objectWriter.Append("type", "numeric");

            var inputAttributes = new Dictionary <string, string>();

            this.InputHtmlAttributes.Each(x => inputAttributes.Add(x.Key, x.Value.ToString()));
            objectWriter.AppendObject("inputAttributes", inputAttributes);

            ClientEvents.SerializeTo(objectWriter);

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }
        public static void AppendContentUrls <TItem>(this IClientSideObjectWriter objectWriter, string identifier, IList <TItem> items, bool isSelfInitialized)
            where TItem : NavigationItem <TItem>, IAsyncContentContainer
        {
            var contentUrls          = new List <string>();
            var hasVisibleAsyncItems = false;

            items.Each(item =>
            {
                if (item.Visible)
                {
                    if (!string.IsNullOrEmpty(item.ContentUrl))
                    {
                        var url = isSelfInitialized
                                      ? System.Web.HttpUtility.UrlDecode(item.ContentUrl)
                                      : item.ContentUrl;

                        contentUrls.Add(url);
                        hasVisibleAsyncItems = true;
                    }
                    else
                    {
                        contentUrls.Add("");
                    }
                }
            });

            if (hasVisibleAsyncItems)
            {
                objectWriter.AppendCollection(identifier, contentUrls);
            }
        }
Exemplo n.º 11
0
 public void SerializeTo(IClientSideObjectWriter writer)
 {
     writer.AppendClientEvent("onLoad", OnLoad);
     writer.AppendClientEvent("onSelectionChange", OnSelectionChange);
     writer.AppendClientEvent("onChange", OnChange);
     writer.AppendClientEvent("onExecute", OnExecute);
 }
 public void SerializeTo(string key, IClientSideObjectWriter writer)
 {
     if (Enabled)
     {
         writer.Append("columnContextMenu", Enabled);
     }
 }
Exemplo n.º 13
0
        public override void WriteInitializationScript(System.IO.TextWriter writer)
        {
            IClientSideObjectWriter objectWriter = ClientSideObjectWriterFactory.Create(Id, "tTextBox", writer);

            objectWriter.Start();

            objectWriter.AppendObject("val", Value);
            objectWriter.Append("step", IncrementStep);
            objectWriter.AppendObject("minValue", MinValue);
            objectWriter.AppendObject("maxValue", MaxValue);
            objectWriter.Append("symbol", PercentSymbol);
            objectWriter.Append("digits", DecimalDigits);
            objectWriter.Append("separator", DecimalSeparator);
            objectWriter.AppendNullableString("groupSeparator", NumberGroupSeparator);
            objectWriter.Append("groupSize", NumberGroupSize);
            objectWriter.Append("positive", PositivePatternIndex);
            objectWriter.Append("negative", NegativePatternIndex);
            objectWriter.Append("text", EmptyMessage);
            objectWriter.Append("type", "percent");

            ClientEvents.SerializeTo(objectWriter);

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }
Exemplo n.º 14
0
 private void SerializeSeriesColors(IClientSideObjectWriter objectWriter)
 {
     if (SeriesColors != null)
     {
         objectWriter.AppendCollection("seriesColors", SeriesColors);
     }
 }
Exemplo n.º 15
0
 private void SerializeTheme(IClientSideObjectWriter objectWriter)
 {
     if (Theme.HasValue())
     {
         objectWriter.Append("theme", Theme);
     }
 }
Exemplo n.º 16
0
 private void SerializeDataBinding(IClientSideObjectWriter objectWriter)
 {
     if (DataBinding.Ajax.Enabled)
     {
         DataBinding.Ajax.SerializeTo("dataSource", objectWriter);
     }
 }
Exemplo n.º 17
0
        public override void WriteInitializationScript(TextWriter writer)
        {
            IClientSideObjectWriter objectWriter = ClientSideObjectWriterFactory.Create(Id, "tSplitter", writer);

            objectWriter.Start();

            objectWriter.Append <SplitterOrientation>("orientation", Orientation, SplitterOrientation.Horizontal);

            var panes = new List <IDictionary <string, object> >();

            Panes.Each(pane =>
            {
                panes.Add(pane.Serialize());
            });

            if (panes.Any())
            {
                objectWriter.AppendCollection("panes", panes);
            }

            ClientEvents.SerializeTo(objectWriter);

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }
Exemplo n.º 18
0
 private void SerializeData(string key, IDictionary <string, object> data, IClientSideObjectWriter objectWriter)
 {
     if (data.Count > 0)
     {
         objectWriter.AppendObject(key, data);
     }
 }
Exemplo n.º 19
0
 public void SerializeTo(IClientSideObjectWriter writer)
 {
     writer.AppendClientEvent("onLoad", OnLoad);
     writer.AppendClientEvent("onChange", OnChange);
     writer.AppendClientEvent("onOpen", OnOpen);
     writer.AppendClientEvent("onClose", OnClose);
 }
Exemplo n.º 20
0
        public void SerializeDataSource(IClientSideObjectWriter writer)
        {
            IEnumerable dataSource          = DataSource;
            var         dataTableEnumerable = DataSource as GridDataTableWrapper;

            var serverOperationMode = !DataBinding.IsClientOperationMode;

            if (serverOperationMode)
            {
                dataSource = DataProcessor.ProcessedDataSource;
            }

            if (dataTableEnumerable != null && dataTableEnumerable.Table != null)
            {
                dataSource = dataSource.SerializeToDictionary(dataTableEnumerable.Table);
            }
            else if (DataProcessor.ProcessedDataSource is IQueryable <AggregateFunctionsGroup> )
            {
                var grouppedDataSource = DataProcessor.ProcessedDataSource.Cast <IGroup>();

                if (serverOperationMode)
                {
                    dataSource = grouppedDataSource.Leaves();
                }
            }

            writer.AppendCollection("data", dataSource);
        }
 public void SerializeTo(IClientSideObjectWriter writer)
 {
     writer.AppendClientEvent("onLoad", OnLoad);
     writer.AppendClientEvent("onChange", OnChange);
     writer.AppendClientEvent("onOpen", OnOpen);
     writer.AppendClientEvent("onClose", OnClose);
 }
Exemplo n.º 22
0
 public void SerializeTo(string key, IClientSideObjectWriter writer)
 {
     if (Enabled)
     {
         writer.Append("selectable", true);
     }
 }
Exemplo n.º 23
0
        public void SerializeTo(string key, IClientSideObjectWriter writer)
        {
            if (Enabled)
            {
                var urlBuilder = grid.UrlBuilder;

                var urls = new Dictionary <string, string>();

                if (Select.HasValue() || (SerializeEmptySelectUrl && !Select.HasValue()))
                {
                    urls["selectUrl"] = Encode(urlBuilder.Url(Select));
                }

                if (Insert.HasValue())
                {
                    urls["insertUrl"] = Encode(urlBuilder.Url(Insert));
                }

                if (Update.HasValue())
                {
                    urls["updateUrl"] = Encode(urlBuilder.Url(Update));
                }

                if (Delete.HasValue())
                {
                    urls["deleteUrl"] = Encode(urlBuilder.Url(Delete));
                }

                writer.AppendObject(key, urls);
            }
        }
Exemplo n.º 24
0
        public override void WriteInitializationScript(TextWriter writer)
        {
            IClientSideObjectWriter objectWriter = ClientSideObjectWriterFactory.Create(Id, "tPanelBar", writer);

            objectWriter.Start();

            if (!defaultEffects.SequenceEqual(Effects.Container))
            {
                objectWriter.Serialize("effects", Effects);
            }

            objectWriter.AppendClientEvent("onExpand", ClientEvents.OnExpand);
            objectWriter.AppendClientEvent("onCollapse", ClientEvents.OnCollapse);
            objectWriter.AppendClientEvent("onSelect", ClientEvents.OnSelect);
            objectWriter.AppendClientEvent("onLoad", ClientEvents.OnLoad);
            objectWriter.AppendClientEvent("onError", ClientEvents.OnError);

            objectWriter.Append("expandMode", (int)ExpandMode);

            objectWriter.AppendContentUrls("contentUrls", Items, IsSelfInitialized);

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }
        public void SerializeTo(string key, IClientSideObjectWriter writer)
        {
            if (!Enabled)
            {
                return;
            }

            var editing = Serialize();

            if (editing.Any())
            {
                writer.AppendObject("editing", editing);
            }

            if (grid.IsClientBinding)
            {
                writer.AppendObject("dataKeys", grid.DataKeys.ToDictionary(dataKey => dataKey.Name, dataKey => (object)dataKey.RouteKey));

                if (!grid.IsEmpty)
                {
                    if (grid.DataProcessor.ProcessedDataSource is IQueryable<AggregateFunctionsGroup>)
                    {
                        IEnumerable<IGroup> grouppedDataSource = grid.DataProcessor.ProcessedDataSource.Cast<IGroup>();
                        writer.AppendCollection("data", grouppedDataSource.Leaves());
                    }
                    else
                    {
                        writer.AppendCollection("data", grid.DataProcessor.ProcessedDataSource);
                    }
                }
            }
        }
Exemplo n.º 26
0
 private void SerializeTransitions(IClientSideObjectWriter objectWriter)
 {
     if (!Transitions)
     {
         objectWriter.Append("transitions", Transitions);
     }
 }
 public void SerializeTo(string key, IClientSideObjectWriter writer)
 {
     if (Enabled)
     {
         writer.Append("columnContextMenu", Enabled);
     }
 }
Exemplo n.º 28
0
 public void SerializeTo(string key, IClientSideObjectWriter writer)
 {
     if (!IsDefault)
     {
         writer.AppendObject(key, ToJson());
     }
 }
        public void SerializeTo(IClientSideObjectWriter writer)
        {
            if (!grid.IsClientBinding)
            {
                grid.Server.Select.RouteValues.Merge(grid.ViewContext.RequestContext.RouteData.Values);

                if (grid.Paging.Enabled)
                {
                    grid.Server.Select.RouteValues[grid.Prefix(GridUrlParameters.CurrentPage)] = "{0}";
                }

                if (grid.Sorting.Enabled)
                {
                    grid.Server.Select.RouteValues[grid.Prefix(GridUrlParameters.OrderBy)] = "{1}";
                }

                if (grid.Grouping.Enabled)
                {
                    grid.Server.Select.RouteValues[grid.Prefix(GridUrlParameters.GroupBy)] = "{2}";
                }

                if (grid.Filtering.Enabled)
                {
                    grid.Server.Select.RouteValues[grid.Prefix(GridUrlParameters.Filter)] = "{3}";
                }

                writer.Append("urlFormat", grid.UrlBuilder.Url(grid.Server.Select, AppendPageSize));
            }
        }
Exemplo n.º 30
0
 /// <summary>
 /// Serializes the client-side events.
 /// </summary>
 /// <param name="writer">The writer object to serialize to.</param>
 public void SerializeTo(IClientSideObjectWriter writer)
 {
     writer.AppendClientEvent("onLoad", OnLoad);
     writer.AppendClientEvent("onDataBound", OnDataBound);
     writer.AppendClientEvent("onDataBinding", OnDataBinding);
     writer.AppendClientEvent("onSeriesClick", OnSeriesClick);
     writer.AppendClientEvent("onError", OnError);
 }
Exemplo n.º 31
0
        public void Create_should_return_correct_instance()
        {
            IClientSideObjectWriterFactory factory = new ClientSideObjectWriterFactory();
            IClientSideObjectWriter        writer  = factory.Create("foo", "bar", new Mock <TextWriter>().Object);

            Assert.NotNull(writer);
            Assert.IsType <ClientSideObjectWriter>(writer);
        }
Exemplo n.º 32
0
}
Exemplo n.º 33
0
 public void SerializeTo(IClientSideObjectWriter writer)
 {
     writer.AppendClientEvent("onLoad", OnLoad);
     writer.AppendClientEvent("onResize", OnResize);
     writer.AppendClientEvent("onExpand", OnExpand);
     writer.AppendClientEvent("onCollapse", OnCollapse);
     writer.AppendClientEvent("onContentLoad", OnContentLoad);
 }
Exemplo n.º 34
0
 public void SerializeTo(IClientSideObjectWriter writer)
 {
     var result = Serialize();
     if (result.Any())
     {
         writer.AppendCollection("plugins", result);
     }
 }
Exemplo n.º 35
0
 public void SerializeTo(IClientSideObjectWriter writer)
 {
     writer.AppendClientEvent("onLoad", OnLoad);
     writer.AppendClientEvent("onResize", OnResize);
     writer.AppendClientEvent("onExpand", OnExpand);
     writer.AppendClientEvent("onCollapse", OnCollapse);
     writer.AppendClientEvent("onContentLoad", OnContentLoad);
 }
 public void SerializeTo(IClientSideObjectWriter writer)
 {
     writer.Append("multiple", Enabled, false);
     if (!Separator.Equals(defaultSeparator))
     {
         writer.Append("separator", Separator);
     }
 }
Exemplo n.º 37
0
 /// <summary>
 /// Serializes the client-side events.
 /// </summary>
 /// <param name="writer">The writer object to serialize to.</param>
 public void SerializeTo(IClientSideObjectWriter writer)
 {
     writer.AppendClientEvent("onLoad", OnLoad);
     writer.AppendClientEvent("onDataBound", OnDataBound);
     writer.AppendClientEvent("onDataBinding", OnDataBinding);
     writer.AppendClientEvent("onSeriesClick", OnSeriesClick);
     writer.AppendClientEvent("onError", OnError);
 }
Exemplo n.º 38
0
 public void SerializeTo(IClientSideObjectWriter writer)
 {
     writer.AppendClientEvent("onLoad", OnLoad);
     writer.AppendClientEvent("onPaste", OnPaste);
     writer.AppendClientEvent("onSelectionChange", OnSelectionChange);
     writer.AppendClientEvent("onChange", OnChange);
     writer.AppendClientEvent("onExecute", OnExecute);
     writer.AppendClientEvent("onError", OnError);
 }
 public void SerializeTo(IClientSideObjectWriter writer)
 {
     writer.AppendClientEvent("onLoad", OnLoad);
     writer.AppendClientEvent("onChange", OnChange);
     writer.AppendClientEvent("onOpen", OnOpen);
     writer.AppendClientEvent("onClose", OnClose);
     writer.AppendClientEvent("onDataBinding", OnDataBinding);
     writer.AppendClientEvent("onDataBound", OnDataBound);
     writer.AppendClientEvent("onError", OnError);
 }
Exemplo n.º 40
0
 public void SerializeTo(IClientSideObjectWriter writer)
 {
     writer.AppendClientEvent("onLoad", OnLoad);
     writer.AppendClientEvent("onChange", OnChange);
     writer.AppendClientEvent("onOpen", OnOpen);
     writer.AppendClientEvent("onClose", OnClose);
     writer.AppendClientEvent("onDataBinding", OnDataBinding);
     writer.AppendClientEvent("onDataBound", OnDataBound);
     writer.AppendClientEvent("onError", OnError);
 }
Exemplo n.º 41
0
        public override void WriteInitializationScript(TextWriter writer)
        {
            IClientSideObjectWriter objectWriter = ClientSideObjectWriterFactory.Create(Id, "tWindow", writer);

            objectWriter.Start();

            if (!defaultEffects.SequenceEqual(Effects.Container))
            {
                objectWriter.Serialize("effects", Effects);
            }

            //client events
            objectWriter.AppendClientEvent("onClose", ClientEvents.OnClose);
            objectWriter.AppendClientEvent("onError", ClientEvents.OnError);
            objectWriter.AppendClientEvent("onLoad", ClientEvents.OnLoad);
            objectWriter.AppendClientEvent("onDragStart", ClientEvents.OnDragStart);
            objectWriter.AppendClientEvent("onDragEnd", ClientEvents.OnDragEnd);
            objectWriter.AppendClientEvent("onOpen", ClientEvents.OnOpen);
            objectWriter.AppendClientEvent("onActivate", ClientEvents.OnActivate);
            objectWriter.AppendClientEvent("onResize", ClientEvents.OnResize);
            objectWriter.AppendClientEvent("onRefresh", ClientEvents.OnRefresh);

            //properties
            objectWriter.Append("modal", Modal);
            objectWriter.Append("contentUrl", ContentUrl);
            objectWriter.Append("draggable", Draggable);
            objectWriter.Append("resizable", ResizingSettings.Enabled);

            if (ResizingSettings.Enabled)
            {
                if (ResizingSettings.MinHeight != int.MinValue)
                {
                    objectWriter.Append("minHeight", ResizingSettings.MinHeight);
                }

                if (ResizingSettings.MinWidth != int.MinValue)
                {
                    objectWriter.Append("minWidth", ResizingSettings.MinWidth);
                }

                if (ResizingSettings.MaxHeight != int.MinValue)
                {
                    objectWriter.Append("maxHeight", ResizingSettings.MaxHeight);
                }

                if (ResizingSettings.MaxWidth != int.MinValue)
                {
                    objectWriter.Append("maxWidth", ResizingSettings.MaxWidth);
                }
            }

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }
 public void SerializeTo(string key, IClientSideObjectWriter writer)
 {
     if (Enabled)
     {
         if (grid.DataProcessor.GroupDescriptors.Any())
         {
             writer.AppendCollection("groups", SerializeDescriptors());
             writer.Append("groupBy", SerializeExpression());
         }
     }
 }
Exemplo n.º 43
0
 public void SerializeTo(string key, IClientSideObjectWriter writer)
 {
     if (Enabled)
     {
         writer.Append("sortMode", SortMode == GridSortMode.MultipleColumn ? "multi" : "single");
         if (grid.DataProcessor.SortDescriptors.Any())
         {
             writer.Append("orderBy", GridDescriptorSerializer.Serialize(grid.DataProcessor.SortDescriptors));
         }
     }
 }
        public void SerializeTo(string key, IClientSideObjectWriter writer)
        {
            if (Format != "{0}" || !Enabled)
            {
                var settings = new Dictionary<string, object>();

                settings["enabled"] = Enabled;
                settings["format"] = Format;

                writer.AppendObject(key, settings);
            }
        }
 public void SerializeTo(string key, IClientSideObjectWriter writer)
 {
     if (Enabled)
     {
         if (EditOnTab)
         {
             writer.AppendObject("keyboardNavigation", new { editOnTab = EditOnTab });
         }
         else
         {
             writer.Append("keyboardNavigation", Enabled);
         }
     }
 }
 /// <summary>
 /// Serializes the binding settings to the specified writer
 /// </summary>
 /// <param name="key">The settings key</param>
 /// <param name="writer">The writer</param>
 public void SerializeTo(string key, IClientSideObjectWriter writer)
 {
     if (Enabled)
     {
         var readUrl = chart.UrlGenerator.Generate(chart.ViewContext.RequestContext, Select);
         writer.AppendObject(key, new
         {
             transport = new
             {
                 read = new
                 {
                     url = readUrl,
                     type = "POST"
                 }
             }
         });
     }
 }
Exemplo n.º 47
0
        public static TreeView CreateTreeView(HtmlTextWriter writer, ITreeViewHtmlBuilder renderer, IClientSideObjectWriter clientSideObjectWriter)
        {
            Mock<HttpContextBase> httpContext = TestHelper.CreateMockedHttpContext();

            if (writer != null)
            {
                httpContext.Setup(c => c.Request.Browser.CreateHtmlTextWriter(It.IsAny<TextWriter>())).Returns(writer);
            }

            urlGenerator = new UrlGenerator();
            authorization = new Mock<INavigationItemAuthorization>();

            Mock<ITreeViewHtmlBuilderFactory> TreeViewRendererFactory = new Mock<ITreeViewHtmlBuilderFactory>();

            Mock<IViewDataContainer> viewDataContainer = new Mock<IViewDataContainer>();

            var viewDataDinctionary = new ViewDataDictionary();
            viewDataDinctionary.Add("sample", TestHelper.CreateXmlSiteMap());

            viewDataContainer.SetupGet(container => container.ViewData).Returns(viewDataDinctionary);

            // needed for testing serialization
            Mock<IClientSideObjectWriterFactory> clientSideObjectWriterFactory = new Mock<IClientSideObjectWriterFactory>();

            viewContext = TestHelper.CreateViewContext();
            viewContext.ViewData = viewDataDinctionary;

            clientSideObjectWriterFactory.Setup(c => c.Create(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<TextWriter>())).Returns(clientSideObjectWriter);

            viewContext = TestHelper.CreateViewContext();
            viewContext.ViewData = viewDataDinctionary;

            authorization.Setup(a => a.IsAccessibleToUser(viewContext.RequestContext, It.IsAny<INavigatable>())).Returns(true);

            TreeView TreeView = new TreeView(viewContext, clientSideObjectWriterFactory.Object, urlGenerator, authorization.Object, TreeViewRendererFactory.Object);

            renderer = renderer ?? new TreeViewHtmlBuilder(TreeView, new Mock<IActionMethodCache>().Object);
            TreeViewRendererFactory.Setup(f => f.Create(It.IsAny<TreeView>())).Returns(renderer);

            return TreeView;
        }
Exemplo n.º 48
0
        /// <summary>
        /// Serializes the asynchronous uploading settings to the writer.
        /// </summary>
        /// <param name="writer">The writer object.</param>
        public void SerializeTo(string key, IClientSideObjectWriter writer)
        {
            if (Save.HasValue())
            {
                Func<string, string> encoder = (string url) => upload.IsSelfInitialized ? HttpUtility.UrlDecode(url) : url;
                var config = new Dictionary<string, object>();

                config["saveUrl"] = encoder(Save.GenerateUrl(upload.ViewContext, upload.UrlGenerator));

                if (SaveField.HasValue())
                {
                    config["saveField"] = SaveField;
                }

                if (Remove.HasValue())
                {
                    config["removeUrl"] = encoder(Remove.GenerateUrl(upload.ViewContext, upload.UrlGenerator));
                }

                config["autoUpload"] = AutoUpload;

                writer.AppendObject(key, config);
            }
        }
Exemplo n.º 49
0
        public void SerializeTo(string key, IClientSideObjectWriter writer)
        {
            if (Enabled)
            {
                writer.Append("pageSize", PageSize, 10);
                writer.Append("total", grid.DataProcessor.Total);
                writer.Append("currentPage", grid.DataProcessor.CurrentPage);
                writer.AppendCollection("pageSizesInDropDown", PageSizesInDropDown.Select(v => v.ToString(CultureInfo.InvariantCulture)));

                writer.Append("pageOnScroll", PageOnScroll);
                if (grid.IsClientBinding && PageOnScroll)
                {
                    if (!grid.IsEmpty)
                    {
                        var dataTableEnumerable = grid.DataSource as GridDataTableWrapper;
                        if (dataTableEnumerable != null && dataTableEnumerable.Table != null)
                        {
                            writer.AppendCollection("data",
                                                    grid.DataProcessor.ProcessedDataSource.SerializeToDictionary(
                                                        dataTableEnumerable.Table));

                        }
                        else if (grid.DataProcessor.ProcessedDataSource is IQueryable<AggregateFunctionsGroup>)
                        {
                            IEnumerable<IGroup> grouppedDataSource = grid.DataProcessor.ProcessedDataSource.Cast<IGroup>();
                            writer.AppendCollection("data", grouppedDataSource.Leaves());
                        }
                        else
                        {
                            writer.AppendCollection("data", grid.DataProcessor.ProcessedDataSource);
                        }
                    }
                }                
            }
            else
            {
                writer.Append("pageSize", 0);
            }
        }
Exemplo n.º 50
0
 public void SerializeTo(string key, IClientSideObjectWriter writer)
 {
     if (!IsDefault)
     {
         writer.AppendObject(key, ToJson());
     }
 }
Exemplo n.º 51
0
 /// <summary>
 /// Serializes the client-side events.
 /// </summary>
 /// <param name="writer">The writer object to serialize to.</param>
 public void SerializeTo(IClientSideObjectWriter writer)
 {
     writer.AppendClientEvent("onLoad", OnLoad);
     writer.AppendClientEvent("onSelect", OnSelect);
     writer.AppendClientEvent("onUpload", OnUpload);
     writer.AppendClientEvent("onSuccess", OnSuccess);
     writer.AppendClientEvent("onError", OnError);
     writer.AppendClientEvent("onComplete", OnComplete);
     writer.AppendClientEvent("onCancel", OnCancel);
     writer.AppendClientEvent("onRemove", OnRemove);
 }
Exemplo n.º 52
0
 public void SerializeTo(string key, IClientSideObjectWriter writer)
 {
     writer.AppendClientEvent("onColumnResize", OnColumnResize);
     writer.AppendClientEvent("onColumnReorder", OnColumnReorder);
     writer.AppendClientEvent("onColumnHide", OnColumnHide);
     writer.AppendClientEvent("onColumnShow", OnColumnShow);
     writer.AppendClientEvent("onCommand", OnCommand);
     writer.AppendClientEvent("onComplete", OnComplete);
     writer.AppendClientEvent("onDelete", OnDelete);
     writer.AppendClientEvent("onDetailViewCollapse", OnDetailViewCollapse);
     writer.AppendClientEvent("onDetailViewExpand", OnDetailViewExpand);
     writer.AppendClientEvent("onDataBinding", OnDataBinding);
     writer.AppendClientEvent("onDataBound", OnDataBound);
     writer.AppendClientEvent("onEdit", OnEdit);
     writer.AppendClientEvent("onError", OnError);
     writer.AppendClientEvent("onLoad", OnLoad);
     writer.AppendClientEvent("onRowDataBound", OnRowDataBound);
     writer.AppendClientEvent("onRowSelect", OnRowSelect);
     writer.AppendClientEvent("onSave", OnSave);
     writer.AppendClientEvent("onSubmitChanges", OnSubmitChanges);
 }
Exemplo n.º 53
0
 public void SerializeTo(string key, IClientSideObjectWriter writer)
 {
     if (Enabled) {
         writer.Append("showOrOption", ShowOrOption, false);
     }
 }
Exemplo n.º 54
0
 public void SerializeTo(string key, IClientSideObjectWriter writer)
 {
     if (Enabled)
     {
         writer.Append("pageSize", PageSize, 10);
         writer.Append("total", grid.DataProcessor.Total);
         writer.Append("currentPage", grid.DataProcessor.CurrentPage);
     }
     else
     {
         writer.Append("pageSize", 0);
     }
 }
        public void SerializeTo(string key, IClientSideObjectWriter writer, IEditorUrlBuilder urlBuilder)
        {
            Func<string, string> encoder = url => owner.IsSelfInitialized ? HttpUtility.UrlDecode(url) : url;
            var json = new Dictionary<string, string>();

            if (Select.HasValue())
            {
                json["selectUrl"] = encoder(urlBuilder.PrepareUrl(Select));
            }

            if (Thumbnail.HasValue())
            {
                json["thumbUrl"] = encoder(urlBuilder.PrepareUrl(Thumbnail));
            }

            if (Image.HasValue())
            {
                json["imageUrl"] = encoder(urlBuilder.PrepareUrl(Image));
            }

            if (Upload.HasValue())
            {
                json["uploadUrl"] = encoder(urlBuilder.PrepareUrl(Upload));
            }

            if (DeleteFile.HasValue())
            {
                json["deleteFileUrl"] = encoder(urlBuilder.PrepareUrl(DeleteFile));
            }

            if (DeleteDirectory.HasValue())
            {
                json["deleteDirectoryUrl"] = encoder(urlBuilder.PrepareUrl(DeleteDirectory));
            }

            if (CreateDirectory.HasValue())
            {
                json["createDirectoryUrl"] = encoder(urlBuilder.PrepareUrl(CreateDirectory));
            }

            if (Filter.HasValue() && Filter != DefaultFilter)
            {
                json["filter"] = Filter;
            }

            writer.AppendObject(key, json);
        }
 public void SerializeTo(IClientSideObjectWriter writer)
 {
     writer.Append("multiple", Enabled, false);
     if (!Separator.Equals(defaultSeparator)) writer.Append("separator", Separator);
 }