private void BuildScripts() { //Empezamos por el Base Script if (String.IsNullOrEmpty(this.Component.HtmlProperties.Id)) { this.Component.HtmlProperties.Id = Resolvers.HtmlResolver.GenerateHtmlValidId(this.ViewContext, typeof(Grid <T>)); } JSBuilder JS = new JSBuilder(); this.Component.Pagination.ToJS(JS); this.Component.Search.ToJS(JS); this.Component.Binding.ToJS(JS); this.Component.Columns.ToJS(JS); this.Component.Options.ToJS(JS); this.Component.Resources.ToJS(JS); //if (this.Component.Size) JS.Add("sDom", "\"<'row'<'col-md-3'l><'col-md-6'f>r>t<'row'<'col-md-3'i><'col-md-6'p>>\""); String basescript = "$('#" + this.Component.HtmlProperties.Id + "').dataTable(" + JS.ToLiteralJSObject(true) + ");"; ((GridScripts)this.Component.Scripts).AddScript(basescript); var scripts = JSResolver.JSStack(ViewContext); scripts.Push(((GridScripts)this.Component.Scripts).GetGeneratedScript()); }
public MvcHtmlString ScriptManager() { var stack = viewContext.HttpContext.Items[JSResolver.JSKey()] as Stack <string>; if (stack == null) { return(MvcHtmlString.Empty); } var scriptTag = new TagBuilder("script"); scriptTag.Attributes["type"] = "text/javascript"; var sb = new StringBuilder(); foreach (var script in stack) { sb.Append(script); } scriptTag.InnerHtml = sb.ToString(); return(new MvcHtmlString(scriptTag.ToString())); }