Пример #1
0
        /// <summary>
        /// Get sort expression and direction into a string as orderby
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        private void SetCustomSortExpression(GridViewSortEventArgs e)
        {
            string sortExpression = e.SortExpression.ToString();

            if (!CustSortExpression.Contains(sortExpression)) //First click on a column
            {
                CustSortExpression = String.Concat(sortExpression, ascStr);
            }
            else //clicks more than once
            {
                if (CustSortExpression.Contains(ascStr))
                {
                    CustSortExpression = String.Concat(sortExpression, descStr);
                }
                else
                {
                    CustSortExpression = String.Concat(sortExpression, ascStr);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Create new header's style
        /// </summary>
        /// <param name="gridViewRow"></param>
        protected void CreateHeader(GridViewRow gridViewRow)
        {
            for (int i = 0; i < this.Columns.Count; i++)
            {
                string    sortExpression = this.Columns[i].SortExpression;
                TableCell tableCell      = gridViewRow.Cells[i];
                //tableCell.CssClass = "GridHeader";

                //Make sure the column we are working with has a sort expression
                if (!string.IsNullOrEmpty(sortExpression) && tableCell.Controls.Count > 0)
                {
                    LinkButton linkButton = tableCell.Controls[0] as LinkButton;
                    if (linkButton != null)
                    {
                        linkButton.Style.Add("width", "100%");
                        linkButton.Style.Add("display", "inline-block");
                        linkButton.Style.Add("text-decoration", "none");
                        linkButton.Style.Add("padding-bottom", this.HeaderPadding);
                        linkButton.Style.Add("padding-top", this.HeaderPadding);
                    }
                    if ((!String.IsNullOrEmpty(CustSortExpression)) && (CustSortExpression.StartsWith(sortExpression)))
                    {
                        Style a = new Style();
                        Color b = ColorTranslator.FromHtml(this.SortColor);

                        a.BackColor = b;
                        tableCell.ApplyStyle(a);
                        //tableCell.CssClass = "GridHeader GridHeader-Active";
                    }
                    tableCell.Style.Add(HtmlTextWriterStyle.Cursor, "hand");
                    tableCell.Style.Add(HtmlTextWriterStyle.Cursor, "pointer");

                    tableCell.Wrap = false;
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Create active sorted row background
        /// </summary>
        /// <param name="gridViewRow"></param>
        protected void CreateRowBackground(GridViewRow gridViewRow)
        {
            if (gridViewRow.RowType == DataControlRowType.DataRow)
            {
                for (int i = 0; i < gridViewRow.Cells.Count; i++)
                {
                    if ((!String.IsNullOrEmpty(CustSortExpression)) && !String.IsNullOrEmpty(this.Columns[i].SortExpression) && (CustSortExpression.StartsWith(this.Columns[i].SortExpression)))
                    {
                        Color sortColumnBgColor;

                        sortColumnBgColor = (gridViewRow.RowState != DataControlRowState.Alternate) ?
                                            ColorTranslator.FromHtml("#d7e3f1") : ColorTranslator.FromHtml("#f7fbff");

                        gridViewRow.Cells[i].BackColor = sortColumnBgColor;
                    }
                }
            }
        }