public static void GridSortInitail(string sortDirection, string sortExpr, GridView grdReport, int formName, object objCollection) { string strSortDir = null; try { switch (sortDirection) { case "Ascending": strSortDir = "ASC"; break; case "Descending": strSortDir = "DESC"; break; } //Appending arrow symbol to the grid header according to the sorting. GridSorting.AppendSortOrderImageToGridHeader("Ascending", sortExpr, ref grdReport); GridSortingEx(0, strSortDir, sortExpr, ref grdReport, objCollection); //Add data to the GridView //GridSorting.MakeAccessible(grdReport); } catch (Exception ex) { //bool rethrow = ExceptionPolicy.HandleException(ex, ARSConstants.StrPerDatumUIPolicy); //if (rethrow) // throw; ////Redirecting to error message page //HttpContext.Current.Server.Transfer(ARSConstants.StrErrorPageURL); } }
/// <summary> /// This event is used to sort the contents of the grid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void GridSort(HtmlInputHidden txthdnSortOrder, GridViewSortEventArgs e, GridView grdReport, int formName, object objCollection) { string strSortDir = null; try { //storing the value in hidden variable if (txthdnSortOrder.Value.Length == 0) { txthdnSortOrder.Value = e.SortDirection.ToString(); } //To reverse the sort order if (txthdnSortOrder.Value.Length != 0) { if (txthdnSortOrder.Value == "Ascending") { txthdnSortOrder.Value = "Descending"; } else { txthdnSortOrder.Value = "Ascending"; } } //checking the condition and sorting accordingly switch (txthdnSortOrder.Value) { case "Ascending": strSortDir = "ASC"; break; case "Descending": strSortDir = "DESC"; break; } //Appending arrow symbol to the grid header according to the sorting. GridSorting.AppendSortOrderImageToGridHeader(txthdnSortOrder.Value, e.SortExpression, ref grdReport); GridSortingEx(formName, strSortDir, e.SortExpression, ref grdReport, objCollection); //Add data to the GridView //GridSorting.MakeAccessible(grdReport); } catch (Exception ex) { //bool rethrow = ExceptionPolicy.HandleException(ex, ARSConstants.StrPerDatumUIPolicy); //if (rethrow) // throw; ////Redirecting to error message page //HttpContext.Current.Server.Transfer(ARSConstants.StrErrorPageURL); } }
/// <summary> /// Render grid /// </summary> /// <param name="t">Grid to render</param> /// <param name="entities">Entities for render</param> /// <param name="mode">Template render mode</param> /// <param name="sorting">Grid sorting</param> /// <returns>Rendered grid as string</returns> public string Render(Type t, PagingCollection<object> entities, TemplateMode mode, GridSorting sorting) { var grid = this.reflector.Reflect(t, mode); if (sorting != null) { grid.Sorting = sorting; } grid.Rows = grid.Rows.OrderBy(r => r.Order).ToList(); var headerRender = this.RenderHeader(grid); var bodyRender = this.RenderBody(grid, entities.CurrentPageCollection.ToList()); return string.Format("<div class=\"enable-grid-hor-overflow\"><table class=\"table table-bordered entity-grid dataTable\">{0}{1}</table></div>{2}", headerRender, bodyRender, this.RenderPaginanation(entities)); }
public static void GridSortForReport(HtmlInputHidden txthdnSortOrder, string eSortExp, GridView grdReport, int formName, object objCollection, string SortDirec) { string strSortDir = null; try { txthdnSortOrder.Value = SortDirec; //checking the condition and sorting accordingly switch (txthdnSortOrder.Value) { case "Ascending": strSortDir = "ASC"; break; case "Descending": strSortDir = "DESC"; break; } //Appending arrow symbol to the grid header according to the sorting. GridSorting.AppendSortOrderImageToGridHeader(txthdnSortOrder.Value, eSortExp, ref grdReport); GridSortingEx(formName, strSortDir, eSortExp, ref grdReport, objCollection); //Add data to the GridView //GridSorting.MakeAccessible(grdReport); } catch (Exception ex) { //bool rethrow = ExceptionPolicy.HandleException(ex, ARSConstants.StrPerDatumUIPolicy); //if (rethrow) // throw; ////Redirecting to error message page //HttpContext.Current.Server.Transfer(ARSConstants.StrErrorPageURL); } }
public ActionResult Index2() { GridModel model = new GridModel(); model.AutoGenerateColumns = false; GridColumn idColumn = new GridColumn(); idColumn.Key = "id"; idColumn.HeaderText = "ID"; idColumn.DataType = "number"; GridColumn NombreColumn = new GridColumn(); NombreColumn.Key = "Nombre"; NombreColumn.HeaderText = "Nombre"; NombreColumn.DataType = "string"; GridColumn ApellidoColumn = new GridColumn(); ApellidoColumn.Key = "Apellido"; ApellidoColumn.HeaderText = "Apellido"; ApellidoColumn.DataType = "string"; GridColumn SexoColumn = new GridColumn(); SexoColumn.Key = "Sexo"; SexoColumn.HeaderText = "Sexo"; SexoColumn.DataType = "string"; GridColumn FechaNacimientoColumn = new GridColumn(); FechaNacimientoColumn.Key = "FechaNacimiento"; FechaNacimientoColumn.HeaderText = "Fecha Nacimiento"; FechaNacimientoColumn.DataType = "datetime"; model.Columns.Add(idColumn); model.Columns.Add(NombreColumn); model.Columns.Add(ApellidoColumn); model.Columns.Add(SexoColumn); model.Columns.Add(FechaNacimientoColumn); //Activando Ordenamiento GridSorting sorting = new GridSorting(); sorting.Mode = SortingMode.Single; ColumnSortingSetting colSetting = new ColumnSortingSetting(); colSetting.ColumnIndex = 1; colSetting.ColumnKey = "Nombre"; colSetting.AllowSorting = true; //Activando Filtrado GridFiltering filtering = new GridFiltering(); ColumnFilteringSetting colFilter = new ColumnFilteringSetting(); colFilter.AllowFiltering = true; sorting.ColumnSettings.Add(colSetting); filtering.ColumnSettings.Add(colFilter); model.Features.Add(sorting); model.Features.Add(filtering); //Activando Paginacion GridPaging gridpaging = new GridPaging(); gridpaging.PageSize = 2; model.Features.Add(gridpaging); model.DataSource = ctx.Alumno.GetAllAlumnos3(); return(View(model)); }
/// <summary> /// Get All States /// </summary> /// <param name="ddlStates"></param> /// <summary> /// This method is used to sort the contents of the gridview /// </summary> /// <param name="formName">Form name </param> /// <param name="sortDir">Sort direction</param> /// <param name="sortExpr">Sort Expression</param> /// <param name="grdReport">Display grid</param> public static void GridSortingEx(int formNameNumber, string sortDir, string sortExpr, ref System.Web.UI.WebControls.GridView grdReport, object objCollection) { GridSorting.GridSort(sortDir, sortExpr, ref grdReport, objCollection, true); }