ext:TabStrip中CheckBoxField造成Button事件异常

Mar 15, 2011 at 7:30 AM

现象:

1:页面中有<Toolbars>中有button用于“保存后关闭”。

2:页面中有一个TabStrip且有至少两个Tab如果非活动Tab中的Grid控件有CcheckBoxField例,那么会造成工具栏中的“保存后关闭”事件响应异常。

3:异常内容: ‘c’ is null or not a object.

测试代码:

[*.aspx]

<body>
    <form id="form1" runat="server">  
    <ext:PageManager ID="PageManager1" runat="server" />
   
     <ext:Form ID="SimpleForm1" ShowBorder="false" ShowHeader="false" runat="server" BodyPadding="5px"
        EnableBackgroundColor="true" Title="SimpleForm"> 
       
         <Toolbars>
            <ext:Toolbar ID="Toolbar1" runat="server">
                <Items>
                    <ext:Button ID="btnClose" Icon="SystemClose" EnablePostBack="false" runat="server"
                        Text="关闭">
                    </ext:Button>
                    <ext:ToolbarSeparator ID="ToolbarSeparator1" runat="server">
                    </ext:ToolbarSeparator>
                    <ext:Button ID="btnSaveClose" ValidateForms="SimpleForm1" Icon="SystemSaveClose"
                        OnClick="btnSaveClose_Click" runat="server" Text="保存后关闭">
                    </ext:Button>
                </Items>
            </ext:Toolbar>
        </Toolbars>
   
        <Rows>
            <ext:FormRow>
            <Items>
                <ext:TabStrip ID="TabStrip1" ShowBorder="true" ActiveTabIndex="0" Height="190px" runat="server">
                    <Tabs>
                   
                        <ext:Tab ID="Tab3" Title="责任人" EnableBackgroundColor="true" BodyPadding="5px" Layout="Fit"
                            runat="server">
                            <Items>
                                <ext:Grid ID="gdPrincipal" runat="server" EnableCheckBoxSelect="false" EnableRowNumber="true"
                                    Title="" ShowHeader="false">
                                    <Columns>
                                        <ext:BoundField DataField="Id" Hidden="true" />
                                        <ext:CheckBoxField DataField="Selected" HeaderText="选择" RenderAsStaticField="false" />
                                        <ext:BoundField DataField="Name" HeaderText="人员名称" ExpandUnusedSpace="True" />                            
                                    </Columns>
                                </ext:Grid>
                        </Items>
                    </ext:Tab>
           
                    <ext:Tab ID="Tab4" Title="创建人" EnableBackgroundColor="true" BodyPadding="5px" Layout="Fit"
                        runat="server">
                        <Items>
                            <ext:Grid ID="gdCreater" runat="server" EnableCheckBoxSelect="false" EnableRowNumber="true"
                                Title="" ShowHeader="false">
                                <Columns>
                                    <ext:BoundField DataField="Id" Hidden="true" />
                                    <ext:CheckBoxField DataField="Selected" HeaderText="选择" RenderAsStaticField="false" />
                                    <ext:BoundField DataField="Name" HeaderText="人员名称" ExpandUnusedSpace="True" />
                                </Columns>
                            </ext:Grid>
                        </Items>
                    </ext:Tab>
                </Tabs>       
                </ext:TabStrip>
            </Items>
            </ext:FormRow>
        </Rows>      
    </ext:Form> 
    </form>
</body>

------------------------------

[*.cs]

 protected void Page_Load(object sender, EventArgs e)
 { }

 protected void btnSaveClose_Click(object sender, EventArgs e)
 {        
 }

 -----------------------

Apr 25, 2011 at 6:53 AM

页面加这么一段js,目的是在加载页面后,先切换 “激活” 一下tab,此属走捷径做法,这样就不会再后台报错了

   <script type="text/javascript">
        function onReady() {                        
           var mainTabStrip = Ext.getCmp('<%= TabStrip1.ClientID %>');
           var tabID3 = '<%= Tab3.ClientID %>';
           var tabID4 = '<%= Tab4.ClientID %>';
           mainTabStrip.setActiveTab(tabID4);
           mainTabStrip.setActiveTab(tabID3);
        }
    </script>

Apr 26, 2011 at 9:03 AM

谢谢!!!
2011-04-26

showjan

发件人: vazumi
发送时间: 2011-04-25 13:53:22
收件人: showjan
抄送:
主题: Re: ext:TabStrip中CheckBoxField造成Button事件异常 [extaspnet:249719]

From: vazumi

页面加这么一段js,目的是在加载页面后,先切换 “激活” 一下tab,此属走捷径做法,这样就不会再后台报错了

<script type="text/javascript">
function onReady() {
var mainTabStrip = Ext.getCmp('<%= TabStrip1.ClientID %>');
var tabID3 = '<%= Tab3.ClientID %>';
var tabID4 = '<%= Tab4.ClientID %>';
mainTabStrip.setActiveTab(tabID4);
mainTabStrip.setActiveTab(tabID3);
}
</script>