前言
从系统改版到现在,将近半年的时间,原本陌生的Ext.NET的UI框架,也慢慢的熟悉了。总的来说,这个UI框架还是很优秀的,但是也没有100%完美的产品(老系统使用easy ui其实也挺好的)。趁着这段时间不忙,来总结下(主要是一些奇怪的问题和一些控件的用法),也欢迎大家的补充及指正。
为什么使用Ext.NET
当初决定改版用EXT.NET,主要是因为兼容浏览器,以及是开发效率高。当然了,有些浏览器的兼容性并不是十分完美,例如ie7。更多优点请参阅@雪雁--http://www.cnblogs.com/codelove/archive/2011/07/22/2114317.html。
开门见山
http://examples.ext.net/ ext.net官网,提供一些简单的demo,这是主要资料的的来源,不过基本呢上能应付开发了。
数字框,初始化时的值必须为数字,如果有异常,初始化的值不值数值类型。当点击ext:Button 的Click事件时,无法监听到Button 的Click事件。很郁闷吧。
html代码
1 <ext:GridPanel ID="GridPanelGrade" AutoScroll="true" trackmouseover="true" AutoDestroy="true" Title="修改"
2 Layout="VBoxLayout" runat="server" Width="960" AutoDoLayout="true" ColumnLines="true"
3 Border="false" striperows="true" Cls="page">
4 <CustomConfig>
5 <ext:ConfigItem Name="AutoHeight" Value="true" Mode="Value">
6 </ext:ConfigItem>
7 <ext:ConfigItem Name="ForceFit" Value="true" Mode="Value">
8 </ext:ConfigItem>
9 <ext:ConfigItem Name="autoScroll" Value="true" Mode="Value">
10 </ext:ConfigItem>
11 <ext:ConfigItem Name="autoWidth" Value="false" Mode="Value">
12 </ext:ConfigItem>
13 </CustomConfig>
14 <Store>
15 <ext:Store ID="StoreGrade" runat="server">
16 <Model>
17 <ext:Model ID="StoreGrade_Mode" runat="server">
18 </ext:Model>
19 </Model>
20 </ext:Store>
21 </Store>
22 <ColumnModel ID="ColumnModel1" runat="server">
23 <Columns>
24 </Columns>
25 </ColumnModel>
26 </ext:GridPanel>
后台代码:
void Innit_DATA()
{
//数据集
List<List<string>> results = new List<List<string>>();
for (int i = 0; i < list_Idx.Count; i++)
{
List<string> ss = new List<string>();
string ssr = Addstep(list_Idx[i].level);
ss.Add(ssr + list_Idx[i].name);
results.Add(ss);
}
List<ColumnBase> extColumnBase = new List<ColumnBase>();
Model _ExtModel = new Model();
#region MyRegion
//构建列头
extColumnBase.Add(new Column
{
ID = "TARGETNAME",
Text = "指标名称",
DataIndex = "TARGETNAME",
Sortable = false,
MenuDisabled = true,
Width = 194,
Flex = 1
});
_ExtModel.Fields.Add(new ModelField("TARGETNAME"));
if (dtsource.Rows.Count > 0)
{
for (int i = 0; i < dtsource.Rows.Count; i++)
{
string ids = "A" + tableName + i;
//extColumnBase.Add(new Column
//{
// ID = ids,
// Text = GetReptorNmae(dtsource.Rows[i][1].ToString()),
// DataIndex = ids,
// Sortable = false,
// MenuDisabled = true,
// Flex = 1
//});
ComponentColumn columm = null;
columm = new ComponentColumn();
columm.ID = ids;
columm.DataIndex = ids;
columm.Text = GetReptorNmae(dtsource.Rows[i][1].ToString());
columm.Flex = 1;
columm.Editor = true;
TextField textField = new TextField();
columm.Component.Add(textField);
extColumnBase.Add(columm);
_ExtModel.Fields.Add(new ModelField(ids));
}
}
//清除旧数据与记录集
this.StoreGrade.Reader.Clear();
this.GridPanelGrade.SelectionModel.Clear();
this.GridPanelGrade.ColumnModel.Columns.Clear();
this.StoreGrade.Model.Clear();
this.StoreGrade.Model.Add(_ExtModel);
this.GridPanelGrade.ColumnModel.Columns.AddRange(extColumnBase);
this.StoreGrade.DataSource = results;
this.StoreGrade.DataBind();
this.GridPanelGrade.Render();
}
效果图: