Aug 25, 2014, 5:11 AM
How could I get the value in code behind and show the text in dropdownlist?
Hi,everyone.
I want to show the text in the dropdownlist and get the value which was selected in the code behind.
I write the code like this,but it doesn't work.
EXT.NET 2.5.2
1、 X.DropDownFieldFor(model => model.ParentId,true)
.Text(Model.ParentOrg.FullName)
In the entity,I can't get the "ParentId" value
2、 X.DropDownFieldFor(model => model.ParentOrg.FullName,true)
In the entity,I can't get the "ParentId" value ,but I can get "ParentOrg.FullName" value
I want to get the "ParentId" value in code behind,and show "ParentOrg.FullName" text in dropdownlist.
How could I do?
I want to show the text in the dropdownlist and get the value which was selected in the code behind.
I write the code like this,but it doesn't work.
EXT.NET 2.5.2
@model Sys.Sys_Organization
@(X.FormPanel()
.ID("PanelList")
.Frame(true)
.AutoScroll(true).JsonSubmit(true)
.BodyPadding(10)
.Layout(LayoutType.Fit)
.FieldDefaults(fd => { fd.LabelWidth = 110; fd.LabelStyle = "color:green;padding-left:4px;"; })
.Items(
X.Container()
.Layout(LayoutType.HBox)
.Items(
X.FieldSet()
.Flex(1)
.Title("Information")
.Layout(LayoutType.Anchor)
.DefaultAnchor("100%").MarginSpec("0 0 10")
.Defaults(X.Parameter().Name("HideEmptyLabel").Value("false").Mode(ParameterMode.Raw))
.Items(
X.DropDownFieldFor(model => model.ParentId,true)
.Text(Model.ParentOrg.FullName)
.FieldLabel("parentTree")
.EmptyText("--- select ---")
.Editable(false)
.Mode(DropDownMode.ValueText)
.TriggerIcon(TriggerIcon.SimpleArrowDown)
.Component(treePanel =>
treePanel.Add(Html.X().TreePanel()
.Height(300)
.Width(500)
.MinWidth(500)
.RootVisible(false)
.SelectionModel(selectionmodel => selectionmodel.Add(Html.X().TreeSelectionModel().Mode(SelectionMode.Single)))
.Store(
Html.X().TreeStore()
.Proxy(
Html.X().AjaxProxy()
.Url(Url.Action("GetNodes"))
)
.Root(
Html.X().Node().NodeID("Root")
)
)
.Listeners(l => {
l.ItemClick.Handler = @"this.dropDownField.setValue(record.data.id, record.data.text, true);";
l.AfterRender.Handler = "this.getRootNode().expand(true);";
l.AfterRender.Delay = 50;
})
)
)
)
)
)
.Buttons(
X.Button()
.ID("Button1")
.Text("Save")
.Icon(Icon.Disk)
.DirectEvents(de =>
{
de.Click.Method = HttpMethod.POST;
de.Click.Url = Url.Action("Save");
de.Click.Success = "saveHandler('EditWindow','PanelList')";
}),
X.Button()
.Text("Cancle")
.Icon(Icon.Cancel)
.Handler("parent.Ext.getCmp('EditWindow').close()")
)
)
controller:
public ActionResult Save(Sys_Organization entity)
{
ServiceFactory.Instance.Get<Sys_OrganizationService>(Sys_Organization).Save(entity);
return this.Direct();
}
I try like this :1、 X.DropDownFieldFor(model => model.ParentId,true)
.Text(Model.ParentOrg.FullName)
In the entity,I can't get the "ParentId" value
2、 X.DropDownFieldFor(model => model.ParentOrg.FullName,true)
In the entity,I can't get the "ParentId" value ,but I can get "ParentOrg.FullName" value
I want to get the "ParentId" value in code behind,and show "ParentOrg.FullName" text in dropdownlist.
How could I do?
Last edited by Dalen; Aug 25, 2014 at 5:42 AM.