0

我正在尝试根据我在 Ext.net 的代码隐藏中选择的单选按钮隐藏 ComboBox 和/或 DateFields

                        <Items>
                            <ext:Container ID="Container1" runat="server" Layout="ColumnLayout" Height="175" Width="418" >
                               <Items>
                                    <ext:RadioGroup  runat="server" ID="ChooseSpan" Selectable="true" ColumnsNumber="1" ColumnWidth="0.50"  >
                                        <Items>
                                            <ext:Radio ID="RadioAll" runat="server" BoxLabel="Show All" InputValue="0" />
                                            <ext:Radio ID="RadioMonth" runat="server" BoxLabel="Choose Date Range(By Month)" InputValue="1" />
                                            <ext:Radio ID="RadioDate" runat="server" BoxLabel="Choose Date Range(By Dates)" InputValue="2" />
                                        </Items>
                                    </ext:RadioGroup>
                                    <ext:Container ID="Container2" runat="server" Layout="RowLayout" Height="175" ColumnWidth="0.50" StyleSpec="margin-top:25px;">
                                        <Items>
                                            <ext:ComboBox runat="server" ID="MonthComboBox" Selectable="true" SelectedIndex="0" >
                                                <Items>
                                                    <ext:ListItem Text="Any Month" Value="0" />
                                                    <ext:ListItem Text="January" Value="1" />   
                                                    <ext:ListItem Text="February" Value="2" />
                                                    <ext:ListItem Text="March" Value="3" />
                                                    <ext:ListItem Text="April" Value="4" />
                                                    <ext:ListItem Text="May" Value="5" />
                                                    <ext:ListItem Text="June" Value="6" />
                                                    <ext:ListItem Text="July" Value="7" />
                                                    <ext:ListItem Text="August" Value="8" />
                                                    <ext:ListItem Text="September" Value="9" />
                                                    <ext:ListItem Text="October" Value="10" />
                                                    <ext:ListItem Text="November" Value="11" />
                                                    <ext:ListItem Text="December" Value="12" />
                                                </Items>
                                            </ext:ComboBox>
                                            <ext:DateField
                                                ID="StartDateField"
                                                runat="server"
                                                FieldLabel="Start"
                                                Vtype="daterange"
                                                AnchorHorizontal="100%"
                                                EnableKeyEvents="true">
                                                <CustomConfig>
                                                    <ext:ConfigItem Name="endDateField" Value="#{EndDateField}" Mode="Value" />
                                                </CustomConfig>
                                                <Listeners>
                                                    <%--<Select Handler="#{DirectMethods}.SubmitDate();" />--%>
                                                </Listeners>
                                            </ext:DateField>

                                            <ext:DateField 
                                                ID="EndDateField" 
                                                runat="server" 
                                                Vtype="daterange"
                                                FieldLabel="End"
                                                AnchorHorizontal="100%"
                                                EnableKeyEvents="true">
                                                <CustomConfig>
                                                    <ext:ConfigItem Name="startDateField" Value="#{StartDateField}" Mode="Value" />
                                                </CustomConfig>
                                                <Listeners>
                                                    <%-- <Select Handler="#{DirectMethods}.SubmitDate();" />--%>
                                                </Listeners>
                                            </ext:DateField>
                                            <ext:Button ID="Next" runat="server" Text="Next" MaxWidth="50" StyleSpec="margin-left:159px; margin-top:150;" >

                                            </ext:Button>
                                        </Items>
                                    </ext:Container>
                                </Items>
                            </ext:Container>
                        </Items>
                    </ext:Panel>
                </Items>

这是使用 C# 背后的代码:

    [DirectMethod]
    public void DateSelection()
    {

        if (ChooseSpan.CheckedItems[0].ID == "RadioAll")
        {
            MonthComboBox.Visible = false;
            StartDateField.Visible = false;
            EndDateField.Visible = false;
        }
        if (ChooseSpan.CheckedItems[0].ID == "RadioMonth")
        {
            MonthComboBox.Visible = true;
            MonthComboBox.Show();
            StartDateField.Visible = false;
            EndDateField.Visible = false;
        }
        if (ChooseSpan.CheckedItems[0].ID == "RadioDate")
        {
            MonthComboBox.Visible = false;
            StartDateField.Visible = true;
            StartDateField.Show();
            EndDateField.Visible = true;
            EndDateField.Show();
        }
    }

我需要 RadioGroup 中的听众来接受这些选择吗?我如何让代码隐藏响应我的选择,并告诉它隐藏与否?

4

1 回答 1

1

请收听 RadioGroup 的 Change 事件以调用服务器方法。

要隐藏/显示组件,请使用 Hidden 属性而不是 Visible 属性。这里有一些关于差异的细节。

您也可以使用 Show 和 Hide 方法。

于 2013-05-01T16:52:05.197 回答