Ext rowEdit上不会触发ValidateEdit事件

时间:2013-12-04 10:20:56

标签: javascript ext.net

首先我的代码没有关注的东西:

<ext:Window ID="CommentPopUp" runat="server">
    <Content>
        <ext:GridPanel ID="gvComment" runat="server">
            <Plugins>
                <ext:RowEditor runat="server" SaveText="Save" >
                    <Listeners>
                        <CancelEdit Handler="DeleteRow()" />
                        <ValidateEdit Handler="ValidateComment()"/>
                    </Listeners>
                </ext:RowEditor>
            </Plugins>
            <ColumnModel>
                <Columns>
                    <ext:Column ColumnID="CommentDate" Header="Date" Align="Center" DataIndex="CommentDate" />
                    <ext:Column ColumnID="CommentCreator" Header="User" DataIndex="CommentCreator" />
                    <ext:Column ColumnID="Comment" Header="Comment" DataIndex="Comment" Width="282" >
                        <Editor>
                            <ext:TextArea ID="CommmentEditor" runat="server" />                                    
                        </Editor>
                    </ext:Column>
                </Columns> 
            </ColumnModel>
        </ext:GridPanel>
    </Content>
</ext:Window>

我的问题是,当我点击rowEditor的保存按钮时ValidateComment()侦听器上的ValidateEdit处理程序永远不会触发,而CancelEdit处理程序运行正常。 我还尝试使用Fn代替Handler,并使用ValidateEdit侦听器直接在GridPanel上进行操作但问题相同。

有关此代码中出错的任何想法?

修改

知道了。

当编辑textArea为空时,没有任何附加内容,但是当它包含一些文本ValidateEdit时会被触发。 所以新问题:

即使编辑字段为空,我可以使用什么处理程序进行拦截点击行编辑器保存按钮?

1 个答案:

答案 0 :(得分:0)

我的测试用例一切正常;

代码背后;

  protected void Page_Load(object sender, EventArgs e)
        {


            str.DataSource = this.Data;
            str.DataBind();
        }


         private object[] Data
    {
        get
        {
            DateTime now = DateTime.Now;

            return new object[]
            {
                new object[] { "", 0.02, now },
                new object[] { "Alcoa Inc", 29.01, now },
                new object[] { "Altria Group Inc", 83.81,now },
                new object[] { "American Express Company", 52.55, now },
                new object[] { "American International Group, Inc.", 64.13, now }

            };

        }

         }

表示层;

<ext:GridPanel ID="gvComment" runat="server">
    <Plugins>
        <ext:RowEditing runat="server" SaveText="Savexx">
            <Listeners>

                <CancelEdit  Handler="alert('bumm delete');">

                </CancelEdit>
                <ValidateEdit Handler="alert('bumm validate');" ></ValidateEdit>
            </Listeners>


        </ext:RowEditing>

    </Plugins>
    <Store>
        <ext:Store runat="server" ID="str">
            <Model>
                <ext:Model runat="server">
                    <Fields>
                        <ext:ModelField Name="Comment"></ext:ModelField>
                        <ext:ModelField Name="CommentCreator"></ext:ModelField>

                        <ext:ModelField Name="CommentDate"></ext:ModelField>

                    </Fields>

                </ext:Model>
            </Model>

        </ext:Store>

    </Store>
    <ColumnModel>
        <Columns>
            <ext:Column ColumnID="CommentDate" runat="server" Header="Date" Align="Center" DataIndex="CommentDate" />
            <ext:Column ColumnID="CommentCreator" runat="server"  Header="User" DataIndex="CommentCreator" />
            <ext:Column ColumnID="Comment" runat="server"  Header="Comment" DataIndex="Comment" Width="282" >
                <Editor>
                    <ext:TextArea ID="CommmentEditor" runat="server" />                                    
                </Editor>
            </ext:Column>
        </Columns> 
    </ColumnModel>
</ext:GridPanel>