Richard.Ma 发表于 2020-11-23 15:28:45

为什么C1Calendar会把CustomizeDate的函数体作为控件本身属性给保持了呢?

疑问:
假如有下面一个C1Calendar控件:
[*]<blockquote>    <script type="text/javascript">

复制代码

指定了OnClientCustomizeDate="CustomizeDate"

为什么会把CustomizeDate的函数体作为控件本身属性给保持了呢?不应该只保持函数名吗

ghostlyt 发表于 2020-11-23 16:00:28

问题补充:
参考以下Asp.net代码:
<%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="C1CalendarDemo._Default" %>

<%@ Register Assembly="C1.Web.Wijmo.Controls.4" Namespace="C1.Web.Wijmo.Controls.C1Calendar" TagPrefix="wijmo" %>
<!DOCTYPE html>

<html lang="en">
<head runat="server">

    <title>C1Calendar Test</title>
    <script type="text/javascript">
      function CustomizeDate($daycell, date, dayType, hover, preview) {
            var blnRet = false;
            if ((date.getFullYear() == 2020 && (date.getMonth() + 1) == 11 && date.getDate() == 11)) {
                $daycell.children('a').css('color', 'Red');
                blnRet = true;
            }
            return blnRet;
      }
    </script>
</head>

<body>
    <form runat="server">
      <div class="row">
            <wijmo:C1Calendar ID="C1Calendar1" runat="server" AutoPostBack="true" Culture="ja-JP" OnClientCustomizeDate="CustomizeDate"></wijmo:C1Calendar>
      </div>
    </form>
</body>
</html>

脚本中定义了一个CustomizeDate方法 使2020-11-11日变红色,然后指定C1Calendar的OnClientCustomizeDate=CustomizeDate。
在点击控件的日期进行PostBack时,可以在F12工具中查看到提交的请求数据中包含以下内容:
   C1Calendar1__jsonserverstate_ffcache: {"disabled":false,"create":null,"initSelector":":jqmData(role='wijcalendar')","culture":"ja-JP","cultureCalendar":"","monthViewTitleFormat":"yyyy","monthCols":1,"monthRows":1,"titleFormat":"yyyy年MMMM","showTitle":true,"dayRows":6,"dayCols":7,"initialView":"day","weekDayFormat":"short","showWeekDays":true,"showWeekNumbers":false,"calendarWeekRule":"firstDay","minDate":"1900-01-01T00:00:00:000Z","maxDate":"2099-12-31T00:00:00:000Z","showOtherMonthDays":true,"showDayPadding":false,"selectionMode":{"day":true,"days":true},"allowPreview":false,"allowQuickPick":true,"toolTipFormat":"yyyy年MMMMdd日","prevTooltip":"前へ","nextTooltip":"次へ","quickPrevTooltip":"クイック+-+前へ","quickNextTooltip":"クイック+-+次へ","prevPreviewTooltip":"","nextPreviewTooltip":"","navButtons":"default","quickNavStep":12,"direction":"horizontal","duration":250,"easing":"easeInQuad","popupMode":false,"autoHide":true,"customizeDate":"function+CustomizeDate($daycell,+date,+dayType,+hover,+preview)+{\r\n++++++++++++var+blnRet+=+false;\r\n++++++++++++if+((date.getFullYear()+==+2020+&&+(date.getMonth()+++1)+==+11+&&+date.getDate()+==+11))+{\r\n++++++++++++++++$daycell.children('a').css('color',+'Red');\r\n++++++++++++++++blnRet+=+true;\r\n++++++++++++}\r\n++++++++++++return+blnRet;\r\n++++++++}","title":null,"beforeSlide":null,"afterSlide":null,"beforeSelect":null,"afterSelect":null,"selectedDatesChanged":null,"postBackEventReference":"__doPostBack('C1Calendar1','{0}')","autoPostBack":true,"disabledDates":[],"selectedDates":["2020-11-12T00:00:00:000Z"],"weekString":"週","displayDate":"2020-11-23T15:57:18:161Z","disabledState":false}上面红色部分,本应该是"customizeDate":"CustomizeDate"才合理吧?

Richard.Ma 发表于 2020-11-23 17:15:14

收到,我测试一下看看
页: [1]
查看完整版本: 为什么C1Calendar会把CustomizeDate的函数体作为控件本身属性给保持了呢?