找回密码
 立即注册

QQ登录

只需一步,快速开始

ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-5-15 12:11:00
51#
Hi sam

我在之前Demo的基础上进行了修改,主要是修改了PopupCellType类型,详细请参考附件,此外还修改了使用PopupCellType页面的Load方法(有一点需要注意,Spread初始状态不能为空,至少需要有1行数据):
  1.     protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         if (IsPostBack)
  4.             return;

  5.         PopupCellType popup = new PopupCellType();
  6.         this.FpSpread1.ActiveSheetView.Columns[0].CellType = popup;
  7.         this.FpSpread1.ActiveSheetView.Cells[0, 0].Value = "请猛烈点击我!!!";

  8.         DateCalendarCellType datecellType = new DateCalendarCellType();
  9.         datecellType.DateFormat = "yyyy-MM-dd";
  10.         this.FpSpread1.ActiveSheetView.Columns[1].CellType = datecellType;

  11.         this.FpSpread1.ActiveSheetView.RowCount = 1;
  12.     }
复制代码
PopupCellType.cs PopupCellType.zip (1.18 KB, 下载次数: 246)
回复 使用道具 举报
sam
论坛元老   /  发表于:2012-5-15 13:29:00
52#
嗨 Dof:

能不能在初始状态,不新增设置一行数据呢?因为我这边的需求就是初始状态是没有行的。
以上能否实现?
谢谢!
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-5-15 17:43:00
53#
Hi sam

如果初始状态没有数据的,点击Add之后就会有异常发生(ModalPopupExtender和DateCalendar一块使用会有冲突,但是其原因还不清楚),如不然就得考虑49楼的方法了。
回复 使用道具 举报
sam
论坛元老   /  发表于:2012-5-15 22:38:00
54#
Hi Dof,

我这边试过了,好像设置任意一个Ajax Extender控件类型(不光是日历类型)都会报错。
你那边是否可以再改改PopupCellType.cs这个类,可以兼容Ajax Extender控件类型列。我觉得应该是我们自定义PopupCellType这个列类型和Ajax Extender类型有冲突.
是否也可以向开发部反馈下这个问题?看如何解决?

麻烦了。Tks!
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-5-16 09:37:00
55#
从错误提示来看,其原因和你的推测应该是一致的,我这边也在调查中
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-5-17 11:15:00
56#
如果通过Button的Click事件来添加行,可以通过附件中的代码来实现(主要修改与51楼相同,修改了PopupCellType的部分代码),然后将Spread本身的Add和Insert功能屏蔽掉。

PopupCellTypeDemo_Modal.zip (903.52 KB, 下载次数: 241)
回复 使用道具 举报
sam
论坛元老   /  发表于:2012-5-17 21:05:00
57#
嗨,Dof:

您好!
我将Spread控件的本身的Insert功能设置为False后是可以了.但是我还想在自定义单元格类型中增加一个属性,用于传值的。改如何增加一个单元格的类型?
在以下类中如何增加一个自定义的属性?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI;

namespace PopupCellTypeDemo_Modal
{
    [Serializable()]
    public class PopupCellType : FarPoint.Web.Spread.GeneralCellType
    {
        public PopupCellType()
        {

        }

        public string jsExecEvent
        {
            //??????????????????
        }


        public override System.Web.UI.Control GetEditorControl(string id, System.Web.UI.WebControls.TableCell parent, FarPoint.Web.Spread.Appearance style, FarPoint.Web.Spread.Inset margin, object value, bool upperLevel)
        {
            Table table = new Table();
            table.CellPadding = 0;
            table.CellSpacing = 0;
            table.BorderStyle = BorderStyle.None;
            table.BorderWidth = new Unit(0, UnitType.Pixel);
            table.Width = new Unit(100, UnitType.Percentage);

            TableRow row = new TableRow();

            TableCell cell = new TableCell();
            cell.VerticalAlign = VerticalAlign.Middle;
            cell.HorizontalAlign = HorizontalAlign.Left;

            // 用户可以直接在 TextBox 中输入数据
            TextBox tb = new TextBox();
            tb.Width = new Unit(99, UnitType.Percentage);
            tb.ID = &quotopupEditor";
            // 如果不希望用户直接输入数据,可以将TextBox设置为ReadOnly,这样就可以保证数据的有效性
            // tb.ReadOnly = true;
            tb.Attributes.Add("onkeydown", "return EnterPress(event);");
            cell.Controls.Add(tb);
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Width = new Unit(22, UnitType.Pixel);
            cell.VerticalAlign = VerticalAlign.Middle;
            cell.HorizontalAlign = HorizontalAlign.Right;

            // 如果用户不想通过输入的方式填写数据,可以点击[检索]按钮,在弹出的窗体中选择需要的数据
            ImageButton img = new ImageButton();
            img.ImageUrl = @"Images/Search.jpg";
            img.BorderColor = System.Drawing.Color.LightGray;
            img.BorderStyle = BorderStyle.Solid;
            img.BorderWidth = new Unit(1, UnitType.Pixel);
            //img.Attributes.Add("onclick", "ShowPopup()");
            img.Attributes.Add("onclick", jsExecEvent);
            cell.Controls.Add(img);
            row.Cells.Add(cell);

            table.Rows.Add(row);

            return table;
        }

        public override System.Web.UI.Control PaintCell(string id, System.Web.UI.WebControls.TableCell parent, FarPoint.Web.Spread.Appearance style, FarPoint.Web.Spread.Inset margin, object value, bool upperLevel)
        {
            System.Web.UI.WebControls.Panel p = new System.Web.UI.WebControls.Panel();
            ApplyStyleTo(parent, style, margin, true);
            if (value != null)
                p.Controls.Add(new LiteralControl(value.ToString()));
            else
                p.Controls.Add(new LiteralControl());
            return p;
        }

        public override string EditorClientScriptUrl
        {
            get
            {
                return &quotopupEditorScript.htc";
            }
        }
    }
}
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-5-18 10:24:00
58#
Hi sam

PopupCellType 最初版本是通过属性来设置js方法的名称,但是为了解决添加行的问题,就改成了固定的写法(而不是通过属性来设置),所以现在通过属性设置调用js方法的名称是不行的。
回复 使用道具 举报
sam
论坛元老   /  发表于:2012-5-18 10:42:00
59#
能不能增加自定义属性呢?
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-5-18 11:07:00
60#
我这边正在调试,请稍等

以下是我对添加数据功能的个人看法:
这几天我妈讨论的添加数据行的问题,是因为Spread初始状态没有数据行,所以页面在注册Ajax控制控件的时候出来些问题。假设Spread初始状态时有1行数据的,我们就可以直接使用Spread的Add方法,而且PopupCellType也可以通过属性来设置js方法。不知将需求调整一下的可能性有多大,如果Spread默认是允许有一行数据,这个人体就简单很多了。

以上纯属我个人看法,绝不影响我们协助解决你的问题。哈哈。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部