第一次接触Ext.Net控件,想实现以上功能,但是我试了几天都不行,求高手指点下
功能如下:
问题项是根据问题类型来加载数据的
部分代码:
//------- Html.X().ComboBox().ID("CbType").Name("CbType").FieldLabel("问题类型").Editable(false).LabelWidth(60).Items( new ListItem { Value = "0", Text = "内部" }, new ListItem { Value = "1", Text = "外部" } ) .SelectedItems(Html.X().ListItem().Value("0").Text("内部")) .Listeners(l => l.Select.Handler = "#{HidType}.setValue(this.getValue());Ext.getCmp('TreePanel1').setRootNode()"), Html.X().Hidden().Name("Type").ID("HidType").Value("0"), //------- Html.X().DropDownField().Name("Level").ID("CBLevel").FieldLabel("问题项").LabelAlign(LabelAlign.Left).LabelWidth(60).AllowBlank(false).Editable(false).Mode(DropDownMode.ValueText).EmptyText("请选择...") .Component(c => c.Add(Html.X().TreePanel().ID("TreePanel1").Shadow(false).UseArrows(true).MaxHeight(250).MinHeight(50).Width(500) .AutoScroll(true).Animate(false).RootVisible(false).Header(false).Root(new Node { NodeID = "-", Text = "Root" }) .Store( Html.X().TreeStore().ID("TreeStore1") .Root(new Node { NodeID = "-", Text = "Root" }) .Proxy(new AjaxProxy { API = { Read = Url.Action("GetLevel") }, ActionMethods = { Read = HttpMethod.GET } }) .Parameters(ps => ps.Add(new StoreParameter("type", "0"))) ) .Listeners(l => { l.ItemClick.Handler = "if(record.childNodes.length>0){Ext.Msg.alert('错误','请选择子节点');}else{this.dropDownField.setValue(record.data.id,record.data.text,true);}"; }) ) )
帮顶~
自己换种方式实现了,数据库设计成3层即可
我用mvc模式做过。你做过TreePanel吗
<ext:ComboBox ID="MIDDLECODE" runat="server" FieldLabel="中类代码" LabelWidth="60" DisplayField="NAME" ValueField="MIDDLECODE" EmptyText="请选择....." AllowBlank="false"> <Store> <ext:Store runat="server" ID="storecboMiddleCode"> <Model> <ext:Model ID="Model2" runat="server" IDProperty="MIDDLECODE" > <Fields> <ext:ModelField Name="MIDDLECODE" ></ext:ModelField> <ext:ModelField Name="NAME"></ext:ModelField> </Fields> </ext:Model> </Model> </ext:Store> </Store> <DirectEvents> <Change OnEvent="CboMiddleCodeChange" /> </DirectEvents> </ext:ComboBox>
<ext:ComboBox ID="SMALLCODE" runat="server" FieldLabel="小类代码" LabelWidth="60" DisplayField="NAME" ValueField="SMALLECODE" EmptyText="请选择....." AllowBlank="false" > <Store> <ext:Store runat="server" ID="storecboSmallCode"> <Model> <ext:Model ID="Model3" runat="server" IDProperty="SMALLCODE"> <Fields> <ext:ModelField Name="SMALLCODE" ></ext:ModelField> <ext:ModelField Name="NAME"></ext:ModelField> </Fields> </ext:Model> </Model> </ext:Store> </Store> </ext:ComboBox>
//中类联动小类
public void CboMiddleCodeChange(object sender, DirectEventArgs e)
{
if (this.MIDDLECODE.SelectedItem != null)
{
string middleType = this.MIDDLECODE.SelectedItem.Value;
CResult Reslut = smallCode_Bus.GetByStr("MIDDLECODE='" + middleType + "'", "SMALLCODE");
if (Reslut.Value != null && Reslut.Success)
{
this.storecboSmallCode.DataSource = Reslut.Value as DataTable;
this.storecboSmallCode.DataBind();
}
}
}