Sep 09, 2013, 8:19 PM
[CLOSED] Multicombo created dynamically not showing selected items
Hi,
Dynamically created multi combobox values are not showing the selected items in the multi combobox. Please check the code below... I have created multi combobox and added some default values and then selected some values from those items in multi combobox. Those selected values are not showing if we add selected values code after "sectionSecAssign.Render(pnlAssignCommon, RenderMode.AddTo)" code in the example. If we add before this statement the selected items are showing up. In my actual application I don't know the value to select in the combobox, we will verify selected items based on some paramenters, and then will add selected items in combobox. It is happening with radio group items also.
Dynamically created multi combobox values are not showing the selected items in the multi combobox. Please check the code below... I have created multi combobox and added some default values and then selected some values from those items in multi combobox. Those selected values are not showing if we add selected values code after "sectionSecAssign.Render(pnlAssignCommon, RenderMode.AddTo)" code in the example. If we add before this statement the selected items are showing up. In my actual application I don't know the value to select in the combobox, we will verify selected items based on some paramenters, and then will add selected items in combobox. It is happening with radio group items also.
<%@ Page Language="VB" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
Dim lstCheck As SortedList
Protected Overrides Sub OnLoad(e As EventArgs)
MyBase.OnLoad(e)
If Not Ext.Net.X.IsAjaxRequest Then
BindData()
End If
End Sub
Private Sub BindData()
Dim i As Integer
For i = 0 To 10
LoadSectionControls(i)
Next
End Sub
Public Sub LoadSectionControls(menuCount As Integer)
Dim lnkAssign As New Ext.Net.MenuItem()
lnkAssign.ID = "mnu" + menuCount.ToString()
lnkAssign.Text = "Assign Users " + menuCount.ToString()
lnkAssign.Icon = Ext.Net.Icon.ArrowRight
lnkAssign.BackColor = System.Drawing.Color.White
If menuCount = 0 Then
pnlFormMenuMain.SelectedIndex = 0
End If
lnkAssign.Listeners.Click.Handler = "SetPanelActiveWindow(" + menuCount.ToString() + ")"
Dim menuSepAssign As New Ext.Net.MenuSeparator()
pnlFormMenuMain.Menu.Add(lnkAssign)
pnlFormMenuMain.Menu.Add(menuSepAssign)
Dim pnlAssignCommon As New Ext.Net.Panel()
pnlAssignCommon.ID = "pnlAssignUsers_" & menuCount.ToString()
pnlAssignCommon.Title = ""
pnlAssignCommon.MonitorResize = True
pnlAssignCommon.Border = False
pnlAssignCommon.Margins = "5,5,5,5"
pnlAssignCommon.BodyStyle = "background-color:#ededed;"
pnlAssignCommon.HideMode = HideMode.Offsets
pnlAssignCommon.Layout = "anchor"
If menuCount < 1 Then
Dim sectionAssign As New FieldSet()
sectionAssign.ID = "fldAssignUsers_" & menuCount.ToString()
sectionAssign.Title = "Assign Users " & menuCount.ToString()
sectionAssign.Collapsible = False
sectionAssign.AutoHeight = True
sectionAssign.BodyStyle = "background-color:#ededed; padding:15px 10px 0px px"
sectionAssign.MonitorResize = True
sectionAssign.Padding = 5
sectionAssign.Layout = "form"
sectionAssign.HideLabels = True
sectionAssign.LabelSeparator = ""
Dim lblFieldDesc As Ext.Net.Label
Dim comFld As Ext.Net.CompositeField
Dim pnlFld As Ext.Net.Panel
comFld = New Ext.Net.CompositeField
comFld.ID = "comFldNum1_" & menuCount.ToString()
comFld.Height = 22
'comFld.Listeners.AfterRender.Handler = "this.innerCt.on('afterlayout', function(){this.layout.innerCt.setHeight(22);});"
pnlFld = New Ext.Net.Panel
pnlFld.Header = False
pnlFld.Width = 20
pnlFld.ID = "pnlCheckListNum1_" & menuCount.ToString()
pnlFld.BodyStyle = "background-color:#ffffff"
pnlFld.Height = Unit.Pixel(20)
lblFieldDesc = New Ext.Net.Label
lblFieldDesc.ID = "lblNum1_" & menuCount.ToString()
lblFieldDesc.Html = "<b><font color='red'>*</font></b>Assign User " & menuCount.ToString()
lblFieldDesc.Icon = Ext.Net.Icon.ApplicationGo
lblFieldDesc.Flex = 10
comFld.Items.Add(pnlFld)
comFld.Items.Add(lblFieldDesc)
Dim txtCustomField As New Ext.Net.NumberField()
txtCustomField.ID = "txtn_" & menuCount.ToString()
txtCustomField.Flex = 8
txtCustomField.DecimalPrecision = 3
txtCustomField.FieldLabel = "Text Field 1"
txtCustomField.AllowBlank = True
comFld.Items.Add(txtCustomField)
sectionAssign.Items.Add(comFld)
pnlAssignCommon.Items.Add(sectionAssign)
Dim sectionSecAssign As New FieldSet()
sectionSecAssign.ID = "fldSecAssignUsers_" & menuCount.ToString()
sectionSecAssign.Title = "Sec Assign Users " & menuCount.ToString()
sectionSecAssign.Collapsible = False
sectionSecAssign.AutoHeight = True
sectionSecAssign.BodyStyle = "background-color:#ededed; padding:15px 10px 0px px"
sectionSecAssign.MonitorResize = True
sectionSecAssign.Padding = 5
sectionSecAssign.Layout = "form"
sectionSecAssign.HideLabels = True
sectionSecAssign.LabelSeparator = ""
Dim lblSecFieldDesc As Ext.Net.Label
Dim comSecFld As Ext.Net.CompositeField
Dim pnlSecFld As Ext.Net.Panel
comSecFld = New Ext.Net.CompositeField
comSecFld.ID = "comSecFldNum1_" & menuCount.ToString()
comSecFld.Height = 22
'comSecFld.Listeners.AfterRender.Handler = "this.innerCt.on('afterlayout', function(){this.layout.innerCt.setHeight(22);});"
pnlSecFld = New Ext.Net.Panel
pnlSecFld.Header = False
pnlSecFld.Width = 20
pnlSecFld.ID = "pnlSecCheckListNum1_" & menuCount.ToString()
pnlSecFld.BodyStyle = "background-color:#ffffff"
pnlSecFld.Height = Unit.Pixel(20)
lblSecFieldDesc = New Ext.Net.Label
lblSecFieldDesc.ID = "lblSecNum1_" & menuCount.ToString()
lblSecFieldDesc.Html = "<b><font color='red'>*</font></b>Assign User " & menuCount.ToString()
lblSecFieldDesc.Icon = Ext.Net.Icon.ApplicationGo
lblSecFieldDesc.Flex = 10
comSecFld.Items.Add(pnlSecFld)
comSecFld.Items.Add(lblSecFieldDesc)
Dim txtSecCustomField As New Ext.Net.NumberField()
txtSecCustomField.ID = "txtSecn_" & menuCount.ToString()
txtSecCustomField.Flex = 8
txtSecCustomField.DecimalPrecision = 3
txtSecCustomField.FieldLabel = "Sec Text Field 1"
txtSecCustomField.AllowBlank = True
comSecFld.Items.Add(txtSecCustomField)
sectionSecAssign.Items.Add(comSecFld)
pnlAssignCommon.Items.Add(sectionSecAssign)
End If
pnlFields.Items.Add(pnlAssignCommon)
End Sub
<DirectMethod()> _
Public Sub SetActiveScreen(menuCount As Integer)
Dim sectionAssign = Ext.Net.X.GetCmp(Of Ext.Net.FieldSet)("fldAssignUsers_" & menuCount.ToString())
If hidCreated.Text = "" Then
hidCreated.Text = "No"
End If
If hidCreated.Text = "No" Then
LoadAllRestOfControls()
End If
'LoadAllRestOfControls()
pnlFields.ActiveIndex = menuCount
End Sub
Public Sub LoadAllRestOfControls()
Dim menuCount As Integer
hidCreated.Text = "Yes"
For menuCount = 1 To 10
Dim pnlAssignCommon = Ext.Net.X.GetCmp(Of Ext.Net.Panel)("pnlAssignUsers_" & menuCount.ToString())
Dim sectionAssign As New FieldSet()
sectionAssign.ID = "fldAssignUsers_" & menuCount.ToString()
sectionAssign.Title = "Assign Users " & menuCount.ToString()
sectionAssign.Collapsible = False
sectionAssign.AutoHeight = True
sectionAssign.BodyStyle = "background-color:#ededed; padding:15px 10px 0px px"
sectionAssign.MonitorResize = True
sectionAssign.Padding = 5
sectionAssign.Layout = "form"
sectionAssign.HideLabels = True
sectionAssign.LabelSeparator = ""
Dim lblFieldDesc As Ext.Net.Label
Dim comFld As Ext.Net.CompositeField
Dim pnlFld As Ext.Net.Panel
comFld = New Ext.Net.CompositeField
comFld.ID = "comFldNum1_" & menuCount.ToString()
comFld.Height = 22
'comFld.Listeners.AfterRender.Handler = "this.innerCt.on('afterlayout', function(){this.layout.innerCt.setHeight(22);});"
pnlFld = New Ext.Net.Panel
pnlFld.Header = False
pnlFld.Width = 20
pnlFld.ID = "pnlCheckListNum1_" & menuCount.ToString()
pnlFld.BodyStyle = "background-color:#ffffff"
pnlFld.Height = Unit.Pixel(20)
lblFieldDesc = New Ext.Net.Label
lblFieldDesc.ID = "lblNum1_" & menuCount.ToString()
lblFieldDesc.Html = "<b><font color='red'>*</font></b>Assign User " & menuCount.ToString()
lblFieldDesc.Icon = Ext.Net.Icon.ApplicationGo
lblFieldDesc.Flex = 10
comFld.Items.Add(pnlFld)
comFld.Items.Add(lblFieldDesc)
Dim txtCustomField As New Ext.Net.NumberField()
txtCustomField.ID = "txtn_" & menuCount.ToString()
txtCustomField.Flex = 8
txtCustomField.DecimalPrecision = 3
txtCustomField.FieldLabel = "Text Field 1"
txtCustomField.AllowBlank = True
comFld.Items.Add(txtCustomField)
sectionAssign.Items.Add(comFld)
'pnlAssignCommon.Items.Add(sectionAssign)
sectionAssign.Render(pnlAssignCommon, RenderMode.AddTo)
Dim sectionSecAssign As New FieldSet()
sectionSecAssign.ID = "fldSecAssignUsers_" & menuCount.ToString()
sectionSecAssign.Title = "Sec Assign Users " & menuCount.ToString()
sectionSecAssign.Collapsible = False
sectionSecAssign.AutoHeight = True
sectionSecAssign.BodyStyle = "background-color:#ededed; padding:15px 10px 0px px"
sectionSecAssign.MonitorResize = True
sectionSecAssign.Padding = 5
sectionSecAssign.Layout = "form"
sectionSecAssign.HideLabels = True
sectionSecAssign.LabelSeparator = ""
Dim lblSecFieldDesc As Ext.Net.Label
Dim comSecFld As Ext.Net.CompositeField
Dim pnlSecFld As Ext.Net.Panel
comSecFld = New Ext.Net.CompositeField
comSecFld.ID = "comSecFldNum1_" & menuCount.ToString()
comSecFld.Height = 22
'comSecFld.Listeners.AfterRender.Handler = "this.innerCt.on('afterlayout', function(){this.layout.innerCt.setHeight(22);});"
pnlSecFld = New Ext.Net.Panel
pnlSecFld.Header = False
pnlSecFld.Width = 20
pnlSecFld.ID = "pnlSecCheckListNum1_" & menuCount.ToString()
pnlSecFld.BodyStyle = "background-color:#ffffff"
pnlSecFld.Height = Unit.Pixel(20)
lblSecFieldDesc = New Ext.Net.Label
lblSecFieldDesc.ID = "lblSecNum1_" & menuCount.ToString()
lblSecFieldDesc.Html = "<b><font color='red'>*</font></b>Assign User " & menuCount.ToString()
lblSecFieldDesc.Icon = Ext.Net.Icon.ApplicationGo
lblSecFieldDesc.Flex = 10
comSecFld.Items.Add(pnlSecFld)
comSecFld.Items.Add(lblSecFieldDesc)
Dim mcCustomField As New Ext.Net.MultiCombo()
mcCustomField.ID = "mcSecn_" & menuCount.ToString()
mcCustomField.Flex = 8
mcCustomField.FieldLabel = "Sec multi combo 1"
mcCustomField.AllowBlank = True
mcCustomField.Items.Add(New Ext.Net.ListItem("Val 1", "1"))
mcCustomField.Items.Add(New Ext.Net.ListItem("Val 2", "2"))
mcCustomField.Items.Add(New Ext.Net.ListItem("Val 3", "3"))
mcCustomField.Items.Add(New Ext.Net.ListItem("Val 4", "4"))
comSecFld.Items.Add(mcCustomField)
sectionSecAssign.Items.Add(comSecFld)
'pnlAssignCommon.Items.Add(sectionSecAssign)
sectionSecAssign.Render(pnlAssignCommon, RenderMode.AddTo)
mcCustomField.SelectedItems.Add(New Ext.Net.SelectedListItem("2"))
mcCustomField.SelectedItems.Add(New Ext.Net.SelectedListItem("3"))
Next
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Ext.NET Example</title>
<script language="javascript" type="text/javascript">
var SetPanelActiveWindow = function (index) {
//Ext.getCmp("pnlFields").layout.setActiveItem(index);
var loadmask = new Ext.LoadMask(Ext.getBody(), { msg: "Please wait..." });
loadmask.show();
Ext.net.DirectMethods.SetActiveScreen(index, {
success: function () {
loadmask.hide();
},
failure: function () {
loadmask.hide();
}
});
};
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="resMngr" runat="server" />
<ext:Viewport ID="vpReqFields" runat="server" Layout="border" StyleSpec="background-color: #C9D9ED;">
<Items>
<ext:Panel ID="pnlAll1003Sections" runat="server" Collapsible="true" Region="West"
Width="220" Split="true" Border="true" Title="Start New Loan" BodyStyle="background-color:#ededed;"
Layout="Border">
<Items>
<ext:Panel ID="pnlLeftCtrls" runat="server" Region="Center" Layout="BorderLayout"
Border="false">
<Items>
<ext:Panel ID="pnl1003Information" runat="server" Title="" Border="false" Icon="Application"
Layout="Border" Region="Center">
<Items>
<ext:MenuPanel ID="pnlFormMenuMain" runat="server" Region="Center" Border="false">
</ext:MenuPanel>
</Items>
</ext:Panel>
</Items>
</ext:Panel>
</Items>
</ext:Panel>
<ext:Panel ID="pnlTabs" runat="server" Region="Center" Layout="BorderLayout" Border="false"
MonitorResize="true">
<Items>
<ext:TabPanel ID="tabSections" runat="server" Title="TabPanel" ActiveIndex="0" Region="Center"
StyleSpec="background-color: #C9D9ED;" Plain="true">
<Items>
<ext:Panel ID="pnlPain" runat="server" BodyStyle="background-color:#ffffff" Border="true"
MonitorResize="true" Title="Loan Data" Layout="BorderLayout">
<Items>
<ext:Panel ID="frmLoan" runat="server" BodyStyle="background-color:#ededed;" MonitorResize="true"
Layout="BorderLayout" Title="" ButtonAlign="Center" Region="Center" Margins="5,5,5,5">
<Items>
<ext:Panel ID="pnlFields" runat="server" Title="Loan" Header="false" Layout="card"
ActiveIndex="0" Padding="20" BodyStyle="background-color:#ededed;" BodyBorder="false"
Region="Center" AutoScroll="true" ButtonAlign="Center">
<TopBar>
<ext:Toolbar ID="tbHeader" runat="server" Height="28">
<Items>
</Items>
</ext:Toolbar>
</TopBar>
<Items>
</Items>
<Buttons>
<ext:Button ID="btnCheck" Text="Read Values" runat="server">
</ext:Button>
</Buttons>
</ext:Panel>
</Items>
</ext:Panel>
</Items>
</ext:Panel>
</Items>
</ext:TabPanel>
</Items>
</ext:Panel>
</Items>
</ext:Viewport>
<ext:Hidden ID="hidCreated" runat="server"></ext:Hidden>
</form>
</body>
</html>
Last edited by Daniil; Sep 17, 2013 at 5:22 AM.
Reason: [CLOSED]