Exemplo n.º 1
0
 protected virtual void OnChangingEntityGridColumnHeader(ChangingEntityGridColumnHeaderEventArgs e)
 {
     if (ChangingEntityGridColumnHeader != null)
         ChangingEntityGridColumnHeader(this, e);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Internals the bind header.
        /// </summary>
        private void internalBindHeader()
        {
            int counter = 0;
            int notMetaFields = 0;
            string key = GetPropertyKey(SortingPropertyKey);

            for (int i = 0; i < this.CustomColumns.Count; i++)
            {
                DataControlField controlField = MainGrid.Columns[i];

                controlField.HeaderText = CHelper.GetResFileString(this.CustomColumns[i].Title);
                controlField.ItemStyle.Width = this.CustomColumns[i].Width;
                controlField.HeaderStyle.Width = this.CustomColumns[i].Width;
                controlField.SortExpression = this.CustomColumns[i].Column.SortExpression;

                // Raising event
                ChangingEntityGridColumnHeaderEventArgs e = new ChangingEntityGridColumnHeaderEventArgs(controlField, this.CustomColumns[i].DataField);
                OnChangingEntityGridColumnHeader(e);

                #region Sorting header text (arrows up/down)
                if (_pc[key] != null)
                {
                    if (_pc[key] == controlField.SortExpression)
                        controlField.HeaderText += String.Format("&nbsp;<img alt='' border='0' src='{0}' />", this.ResolveUrl("~/images/IbnFramework/sort_asc.gif"));
                    else if (_pc[key] == controlField.SortExpression + " DESC")
                        controlField.HeaderText += String.Format("&nbsp;<img alt='' border='0' src='{0}' />", this.ResolveUrl("~/images/IbnFramework/sort_desc.gif"));
                }
                #endregion

                notMetaFields++;
            }
            counter += this.CustomColumns.Count;

            foreach (EntityFieldInfo field in this.VisibleMetaFields)
            {
                int cellWidth = GetMetaFieldWidth(counter - notMetaFields, field.Width);

                MainGrid.Columns[counter].ItemStyle.Width = cellWidth;
                MainGrid.Columns[counter].HeaderStyle.Width = cellWidth;

                if (Mediachase.Ibn.Core.MetaDataWrapper.IsSortable(field.Field) && !field.Field.IsAggregation)
                {
                    string sortExpr = field.Field.Name;
                    if (field.IsAggregation)
                        sortExpr = String.Format("{0}.{1}", field.OwnFieldName, sortExpr);
                    MainGrid.Columns[counter].SortExpression = sortExpr;
                }

                DataControlField controlField = MainGrid.Columns[counter];
                if (!String.IsNullOrEmpty(field.Title))
                    controlField.HeaderText = CHelper.GetResFileString(field.Title);
                else
                    controlField.HeaderText = CHelper.GetResFileString(field.Field.FriendlyName);

                // Raising event
                ChangingEntityGridColumnHeaderEventArgs e = new ChangingEntityGridColumnHeaderEventArgs(controlField, field.OwnFieldName);
                OnChangingEntityGridColumnHeader(e);

                #region Sorting header text (arrows up/down)
                if (_pc[key] != null)
                {
                    if (_pc[key] == controlField.SortExpression)
                        controlField.HeaderText += String.Format("&nbsp;<img alt='' border='0' src='{0}' />", this.ResolveUrl("~/images/IbnFramework/sort_asc.gif"));
                    else if (_pc[key] == controlField.SortExpression + " DESC")
                        controlField.HeaderText += String.Format("&nbsp;<img alt='' border='0' src='{0}' />", this.ResolveUrl("~/images/IbnFramework/sort_desc.gif"));
                }
                #endregion

                counter++;
            }
        }