EXT.NET常用控件使用

(一)ComboBox的使用

1:绑定静态数据

<ext:ComboBox ID="cbSt" runat="server" FieldLabel="状态" LabelWidth="35" AnchorHorizontal="100%"
  LabelSeparator=":" AllowBlank="false">
  <Items>
    <ext:ListItem Text="启用" Value="1" />
    <ext:ListItem Text="停用" Value="2" />
  </Items>
</ext:ComboBox>

<ext:ComboBox runat="server" ID="cbState" SelectedIndex="0" LabelSeparator=":" FieldLabel="付款状态"
AnchorHorizontal="100%" LabelWidth="50">
  <Items>
    <ext:ListItem Text="全部" Value="0" />
    <ext:ListItem Text="全付完" Value="1" />
    <ext:ListItem Text="未付完" Value="2" />
  </Items>
</ext:ComboBox>

2:绑定动态数据

<ext:ComboBox ID="cbRole" runat="server" FieldLabel="角色" LabelSeparator=":" AnchorHorizontal="100%"
AllowBlank="true" StoreID="StoreRole" DisplayField="RoleName" ValueField="ID"
EmptyText="请选择" />

store数据绑定:

<ext:Store ID="StoreRole" runat="server" OnRefreshData="StoreRole_OnRefreshData">
<Reader>
<ext:JsonReader IDProperty="ID">
<Fields>
<ext:RecordField Name="ID" />
<ext:RecordField Name="RoleName" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>

后台获取VALUE: 

StoreRole.DataSource = HJ.Role.ToList();
StoreRole.DataBind();

int RoleID = Convert.ToInt32(cbRole.SelectedItem.Value);

 

(二)控件颜色控制

<ext:Column Header="应付款" DataIndex="Payables" Width="50">
<Renderer Fn="change1" />
</ext:Column>
<ext:Column Header="已付款" DataIndex="Paid" Width="50">
<Renderer Fn="change2" />
</ext:Column>
<ext:Column Header="未付款" DataIndex="Nonpayment" Width="50">
<Renderer Fn="change3" />
</ext:Column>

JS控制

var template = '<span style="color:{0}; font-weight: bolder;font-size: 14px;">{1}</span>';

var change1 = function (value) {
return String.format(template, (value > 0) ? "red" : "red", value).toString();
};
var change2 = function (value) {
return String.format(template, (value > 0) ? "blue" : "blue", value).toString();
};
var change3 = function (value) {
return String.format(template, (value > 0) ? "Green" : "Green", value).toString();
};

 补充:

(1)
string p1 = "Jackie";
string p2 = "Aillo";
Response.Write(String.Format("Hello {0}, I'm {1}", p1, p2));
(2)
Response.Write(String.Format("Hello {0}, I'm {1}", "Jackie", "Aillo"));

这二者的效果是一样的。都是将最后面的两项的值分别替换第一项的{0}和{1}。
输出的结果是:Hello Jackie, I'm Aillo

 

 

 

 

posted on 2012-07-17 21:05  疯狂的石头陈  阅读(410)  评论(0编辑  收藏  举报

导航