public void ToJS(JSBuilder js) { if (this.component.collection.Count > 0) { JSBuilder Maindeclaration = new JSBuilder(); StringBuilder stringBuilder = new StringBuilder(); foreach (var element in this.component.collection) { //Creo un JSBuilderElement para declarar un Literal Object, y luego realizaré el toString var jsBuilderElement = new JSBuilder(); if (!element.visible) { jsBuilderElement.Add("bVisible", "false"); } if (!element.sorting) { jsBuilderElement.Add("bSortable", "false"); } if (!element.filtering) { jsBuilderElement.Add("bSearchable", "false"); } string aTargets = String.Format("[{0}]", element.Index); jsBuilderElement.Add("aTargets", aTargets); stringBuilder.AppendFormat("{0},", jsBuilderElement.ToLiteralJSObject(true)); } stringBuilder.Remove(stringBuilder.Length - 1, 1); String columnDefs = String.Format("[{0}]", stringBuilder.ToString()); js.Add("aoColumnDefs", columnDefs); } }
public void ToJS(JSBuilder js) { if (Component.IsRemote && !String.IsNullOrEmpty(Component.Action)) { //js.Add("bProcessing", "true"); js.Add("bServerSide", "true"); js.Add("sAjaxSource", this.Component.ActionToJSValue()); } }
public void ToJS(JSBuilder JS) { if (this.Component.ActivateSearch) { JS.Add("bFilter", "true"); } else { JS.Add("bFilter", "false"); } }
public void ToJS(JSBuilder js) { if (this.Component.cacheViewedPages) { js.Add("bStateSave", "true"); } }
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 void ToJS(JSBuilder js) { #region pagination if (this.Component.IsPaginable) { js.Add("bPaginate", "true"); if (!this.Component.CanDisplayPaginationOptions) { js.Add("bLengthChange", "false"); } if (this.Component.RowsPerPage != 10) { js.Add("iDisplayLength", this.Component.RowsPerPage.ToString()); } } else { js.Add("bPaginate", "false"); } #endregion }
public void ToJS(JSBuilder js) { /* * "sLengthMenu": 'Display <select>' + * '<option value="10">10</option>' + * '<option value="20">20</option>' + * '<option value="50">50</option>' + * '<option value="100">100</option>' + * '<option value="-1">all</option>' + * '</select> ids' * } */ JSBuilder jsInternal = new JSBuilder(); #region General jsInternal.Add("sProcessing", String.Format("\"{0}\"", Sushi.Resources.Resources.gridProcessing)); jsInternal.Add("sZeroRecords", String.Format("\"{0}\"", Sushi.Resources.Resources.gridZeroRecords)); jsInternal.Add("sInfo", String.Format("\"{0}\"", Sushi.Resources.Resources.gridInfo)); jsInternal.Add("sInfoEmpty", String.Format("\"{0}\"", Sushi.Resources.Resources.gridInfoEmpty)); jsInternal.Add("sInfoFiltered", String.Format("\"{0}\"", Sushi.Resources.Resources.gridInfoFiltered)); jsInternal.Add("sInfoPostFix", String.Format("\"{0}\"", Sushi.Resources.Resources.gridInfoPostFix)); jsInternal.Add("sSearch", String.Format("\"{0}\"", Sushi.Resources.Resources.gridSearch)); jsInternal.Add("sUrl", String.Format("\"{0}\"", Sushi.Resources.Resources.gridUrl)); jsInternal.Add("sLengthMenu", String.Format("\"{0}\"", Sushi.Resources.Resources.gridLengthMenu)); #endregion #region pagination JSBuilder jsPagination = new JSBuilder(); jsPagination.Add("sFirst", String.Format("\"{0}\"", Sushi.Resources.Resources.gridFirst)); jsPagination.Add("sLast", String.Format("\"{0}\"", Sushi.Resources.Resources.gridLast)); jsPagination.Add("sNext", String.Format("\"{0}\"", Sushi.Resources.Resources.gridNext)); jsPagination.Add("sPrevious", String.Format("\"{0}\"", Sushi.Resources.Resources.gridPrevious)); jsInternal.Add("oPaginate", jsPagination.ToLiteralJSObject(true)); #endregion //jsInternal.Add("sLenghtMenu", String.Format("\"{0}\"", Sushi.Resources.Resources.gridLengthMenu)); js.Add("oLanguage", jsInternal.ToLiteralJSObject(true)); }