Как я могу скрыть выходные при использовании Календарного управления ASP.NET?

  1. установить переменную env export LDFLAGS=-Wl,-rpath=.
  2. установить переменную env export NPY_DISTUTILS_APPEND_FLAGS=1
  3. обновить numpy до 1.16.0 или выше
  4. Хотя Вы не можете передать флаги компоновщика из командной строки в f2py, он будет читать переменную окружения LDFLAGS. Однако стандартное поведение для numpy заключается в том, чтобы перезаписывать флаги , используемые при компиляции, а не добавлять их, что приведет к сбою при компиляции, если требуемые флаги отсутствуют в LDFLAGS. В numpy версии 1.16.0 была добавлена ​​поддержка для необязательного добавления этих флагов компоновщика путем установки переменной среды NPY_DISTUTILS_APPEND_FLAGS=1

    >>> unset LD_LIBRARY_FLAGS   # just in case was set before
    >>> export LDFLAGS=-Wl,-rpath=.
    >>> export NPY_DISTUTILS_APPEND_FLAGS=1
    >>> python3 -m numpy.f2py -c progpy.f lib.so -m prog
    >>> python3 test.py
        hello world
    
6
задан rjzii 16 February 2009 в 20:07
поделиться

3 ответа

Поскольку управление обеспечивается, нет никакого способа сделать это, не переопределяя управление. Один способ сделать это к, должен переопределить OnDayRender и Методы рендеринга для удаления информации из вывода до передачи обратно его клиенту.

Следующее является снимком экрана того, на что похоже управление при рендеринге:

Example of weekday calendar

Следующее является основным переопределением управления, которое демонстрирует удаление дневных столбцов выходных дней от управления.

/*------------------------------------------------------------------------------
 * Author - Rob (http://stackoverflow.com/users/1185/rob)
 * -----------------------------------------------------------------------------
 * Notes
 * - This might not be the best way of doing things, so you should test it
 *   before using it in production code.
 * - This control was inspired by Mike Ellison's article on The Code Project
 *   found here: http://www.codeproject.com/aspnet/MellDataCalendar.asp
 * ---------------------------------------------------------------------------*/
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.IO;
using System.Xml;

namespace DataControls
{
    /// <summary>
    /// Example of a ASP.NET Calendar control that has been overriden to force
    /// the weekend columns to be hidden on demand.
    /// </summary>
    public class DataCalendar : Calendar
    {
        private bool _hideWeekend;
        private int _saturday;
        private int _sunday;

        /// <summary>Constructor</summary>
        public DataCalendar()
            : base()
        {
            // Default to showing the weekend
            this._hideWeekend = false;
            // Set the default values for Saturday and Sunday
            this.Saturday = 6;
            this.Sunday = 0;
        }

        /// <summary>
        /// Indicate if the weekend days should be shown or not, set to true
        /// if the weekend should be hidden, false otherwise. This field 
        /// defaults to false.
        /// </summary>
        public bool HideWeekend
        {
            get { return this._hideWeekend; }
            set { this._hideWeekend = value; }
        }

        /// <summary>
        /// Override the default index for Saturdays.
        /// </summary>
        /// <remarks>This option is provided for internationalization options.</remarks>
        public int Saturday 
        {
            get { return this._saturday; }
            set { this._saturday = value; }
        }


        /// <summary>
        /// Override the default index for Sundays.
        /// </summary>
        /// <remarks>This option is provided for internationalization options.</remarks>
        public int Sunday 
        {
            get { return this._sunday; }
            set { this._sunday = value; }
        }

        /// <summary>
        /// Render the day on the calendar with the information provided.
        /// </summary>
        /// <param name="cell">The cell in the table.</param>
        /// <param name="day">The calendar day information</param>
        protected override void OnDayRender(TableCell cell, CalendarDay day)
        {
            // If this is a weekend day and they should be hidden, remove
            // them from the output
            if (day.IsWeekend && this._hideWeekend)
            {
                day = null;
                cell.Visible = false;
                cell.Text = string.Empty;
            }
            // Call the base render method too
            base.OnDayRender(cell, day);
        }

        /// <summary>
        /// Render the calendar to the HTML stream provided.
        /// </summary>
        /// <param name="html">The output control stream to write to.</param>
        protected override void Render(HtmlTextWriter html)
        {
            // Setup a new HtmlTextWriter that the base class will use to render
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter calendar = new HtmlTextWriter(sw);
            // Call the base Calendar's Render method allowing OnDayRender() 
            // to be executed.
            base.Render(calendar);
            // Check to see if we need to remove the weekends from the header,
            // if we do, then remove the fields and use the new verison for
            // the output. Otherwise, just use what was previously generated.
            if (this._hideWeekend && this.ShowDayHeader)
            {
                // Load the XHTML to a XML document for processing
                XmlDocument xml = new XmlDocument();
                xml.Load(new StringReader(sw.ToString()));
                // The Calendar control renders as a table, so navigate to the
                // second TR which has the day headers.
                XmlElement root = xml.DocumentElement;
                XmlNode oldNode = root.SelectNodes("/table/tr")[1];
                XmlNode sundayNode = oldNode.ChildNodes[this.Sunday];
                XmlNode saturdayNode = oldNode.ChildNodes[this.Saturday];
                XmlNode newNode = oldNode;
                newNode.RemoveChild(sundayNode);
                newNode.RemoveChild(saturdayNode);
                root.ReplaceChild(oldNode, newNode);
                // Replace the buffer
                html.WriteLine(root.OuterXml);
            }
            else
            {
                html.WriteLine(sw.ToString());
            }
        }
    }
}
7
ответ дан 17 December 2019 в 00:15
поделиться

Поскольку далеко я знаю, что Вы не можете, но можно экспериментировать с WeekendDayStyle, например, путем установки стиля с display:none., С другой стороны, можно создать пользовательский элемент управления, наследованный от Календаря, и переопределить Рендеринг эфира, OnDayRender или что-то еще.

0
ответ дан 17 December 2019 в 00:15
поделиться

Я полагаю, что можно обработать событие Day Render и скрыть ячейку или присвоить свойства CSS для создания этого невидимым или grayed. Ниже простой пример, я надеюсь, что это помогает.

protected void Calendar_DayRender(object sender, DayRenderEventArgs e)
{

  e.Cell.Visible = False;
  // or
  // e.Cell.Attributes.Add("class", "Invisible");
  // or
  // e.Cell.Attributes.Add("style", "display: none");
}
0
ответ дан 17 December 2019 в 00:15
поделиться
Другие вопросы по тегам:

Похожие вопросы: