请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册

QQ登录

只需一步,快速开始

Richard.Ma 讲师达人认证 悬赏达人认证 SpreadJS 开发认证

超级版主

105

主题

5354

帖子

2万

积分

超级版主

Rank: 8Rank: 8

积分
27403

SpreadJS 认证SpreadJS 高级认证讲师达人悬赏达人

Richard.Ma 讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2020-11-23 15:28  /   查看:116  /  回复:2
疑问:
假如有下面一个C1Calendar控件:
  • <blockquote>    <script type="text/javascript">

[color=rgb(137, 92, 220) !important]复制代码


指定了OnClientCustomizeDate="CustomizeDate"

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

2 个回复

倒序浏览
ghostlyt
中级会员   /  发表于:2020-11-23 16:00:28
沙发
问题补充:
参考以下Asp.net代码:
  1. <%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="C1CalendarDemo._Default" %>

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

  4. <html lang="en">
  5. <head runat="server">

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

  18. <body>
  19.     <form runat="server">
  20.         <div class="row">
  21.             <wijmo:C1Calendar ID="C1Calendar1" runat="server" AutoPostBack="true" Culture="ja-JP" OnClientCustomizeDate="CustomizeDate"></wijmo:C1Calendar>
  22.         </div>
  23.     </form>
  24. </body>
  25. </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讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2020-11-23 17:15:14
板凳
收到,我测试一下看看
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册