首页 > Web开发 > 详细

Ext.Net学习笔记20:Ext.Net FormPanel 复杂用法

时间:2014-02-26 22:52:07      阅读:797      评论:0      收藏:0      [点我收藏+]

在上一篇笔记中我们介绍了Ext.Net的简单用法,并创建了一个简单的登录表单。今天我们将看一下如何更好是使用FormPanel,包括使用字段默认值、Checkbox Grouping和Radio Button Grouping等。

为FormPanel设置默认值

在Form中设置FieldDefaults标签可以设置字段属性的默认值。来看一下我们的用法:

<FieldDefaults LabelWidth="60" LabelAlign="Right">
</FieldDefaults>

在这段代码中,我设置了LabelWidth和LabelAlign属性,那么在Form中的所有字段的Label宽度都设置为60,而对齐方式都是右对齐。

Checkbox Grouping和RadioButton Grouping

checkbox和radiobutton是比较特殊的字段,它们通常不是单独出现的,因此我们需要在Form中使用Checkbox组和RadioButton组来组织多个项。

首先来看一下RadioButton的用法:

<ext:RadioGroup runat="server" Width="400" ColumnsNumber="3" Vertical="true">
    <Items>
        <ext:Radio BoxLabel="Item 1" />
        <ext:Radio BoxLabel="Item 2" Checked="true" />
        <ext:Radio BoxLabel="Item 3" />
        <ext:Radio BoxLabel="Item 4" />
        <ext:Radio BoxLabel="Item 5" />
    </Items>
</ext:RadioGroup>

我们定义了一个RadioGroup,它的子项为Radio的集合,效果如下图:

bubuko.com,布布扣

它的ColumnsNumber属性控制显示的列数,Vertical属性控制显示的方向,为true表示纵向排列,如果吧Vertical属性设置为false,相应的效果图如下:

bubuko.com,布布扣

CheckboxGroup的用法与RadioGroup相同,不再赘言。

FieldSet用法

FieldSet显示一个fieldset html元素,但与html元素不同的是它可折叠。

bubuko.com,布布扣

代码如下:

<ext:FieldSet runat="server" Collapsible="true" Collapsed="false" Title="基本信息">
    <Items>
        <ext:TextField runat="server" FieldLabel="姓名"></ext:TextField>
        <ext:TextField runat="server" FieldLabel="密码"></ext:TextField>
    </Items>
</ext:FieldSet>

FieldContainer 用法

FieldContainer组件用来将字段组合起来显示,效果如下:

bubuko.com,布布扣

代码如下:

<ext:FieldContainer runat="server" FieldLabel="地址" Layout="HBoxLayout">
    <Items>
        <ext:TextField runat="server" EmptyText="河南" IndicatorText="省" Width="100"></ext:TextField>
        <ext:TextField runat="server" EmptyText="洛阳" IndicatorText="市" Width="100"></ext:TextField>
        <ext:TextField runat="server" EmptyText="洛龙区" IndicatorText="区" Width="120"></ext:TextField>
    </Items>
</ext:FieldContainer>

FormPanel布局

下面演示一个FormPanel常用的布局,代码如下:

<ext:Window runat="server" Title="Form 布局" Width="500" Height="300" Layout="FitLayout">
    <Items>
        <ext:FormPanel runat="server" BodyPadding="5" Layout="VBoxLayout">
            <LayoutConfig>
                <ext:VBoxLayoutConfig Align="Stretch"></ext:VBoxLayoutConfig>
            </LayoutConfig>
            <FieldDefaults LabelWidth="60" LabelAlign="Right">
            </FieldDefaults>
            <Items>
                <ext:FieldContainer runat="server" Layout="HBoxLayout">
                    <Items>
                        <ext:TextField runat="server" ID="txtOrderNO" FieldLabel="订单编号" Flex="1"></ext:TextField>
                        <ext:TextField runat="server" ID="txtLocation" FieldLabel="签订地点" Flex="1"></ext:TextField>
                    </Items>
                </ext:FieldContainer>
                <ext:TextArea runat="server" ID="txtRemark" FieldLabel="备注"></ext:TextArea>
            </Items>
            <Buttons>
                <ext:Button runat="server" ID="btnOK" Icon="Accept" Text="确定"></ext:Button>
                <ext:Button runat="server" ID="btnCancel" Icon="Cancel" Text="取消"></ext:Button>
            </Buttons>
        </ext:FormPanel>
    </Items>
</ext:Window>

效果如下图:

bubuko.com,布布扣

 

本文由起飞网原创首发,转载请注明出处。

原文链接:Ext.Net学习笔记20:Ext.Net FormPanel 复杂用法

Ext.Net学习笔记20:Ext.Net FormPanel 复杂用法,布布扣,bubuko.com

Ext.Net学习笔记20:Ext.Net FormPanel 复杂用法

原文:http://www.cnblogs.com/youring2/p/3568373.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!