PDA

View Full Version : [CLOSED] when bind from panel with datasource MultiCombo control not work properly



legaldiscovery
Aug 22, 2013, 9:43 AM
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MultiComboBox.aspx.cs" Inherits="MultiComboBox" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!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 runat="server">
<title></title>
<script type="text/javascript">
var FromLoaded = function (store, records) {
if (Ext.getCmp('fpnlEdit') != undefined) {
if (records.length > 0) {
fpnlEdit.form.loadRecord(records[0]);
}
}
};
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="RMS" runat="server" Namespace="">
</ext:ResourceManager>
<ext:Store ID="fpnlEdit_Store" runat="server">
<Listeners>
<Load Fn="FromLoaded" />
</Listeners>
</ext:Store>
<ext:Viewport runat="server" ID="vpItemAdd" Layout="BorderLayout">
<Items>
<ext:FormPanel ID="fpnlEdit" runat="server" Border="false" ButtonAlign="Left" AutoScroll="true"
Title="Add Details" BodyPadding="50" Region="Center">
<Items>
<ext:FieldSet ID="FsEdit" runat="server" Border="false" Layout="FormLayout">
<Items>
<ext:MultiCombo ID ="ddlMulti" FieldLabel="Items" runat="server" EmptyText="Select" Name="EtextValue" SelectionMode="Selection">
<Items>
<ext:ListItem Text="Item 1" Value="1">
</ext:ListItem>
<ext:ListItem Text="Item 2" Value="2">
</ext:ListItem>
<ext:ListItem Text="Item 3" Value="3">
</ext:ListItem>
<ext:ListItem Text="Item 4" Value="4">
</ext:ListItem>
<ext:ListItem Text="Item 5" Value="5">
</ext:ListItem>
</Items>
</ext:MultiCombo>
</Items>
</ext:FieldSet>
</Items>
</ext:FormPanel>
</Items>
</ext:Viewport>
</form>
</body>
</html>


Server side binding code as below:


DataTable dt = new DataTable();
dt.Columns.Add("EtextValue", typeof(string));
DataRow dr = dt.NewRow();
dr["EtextValue"] = "1,4";
dt.Rows.Add(dr);
fpnlEdit_Store.DataSource = dt;
fpnlEdit_Store.DataBind();


Its work in Ext.net 1.7 but not work in Ext.net 2.2.

Vladimir
Aug 22, 2013, 9:47 AM
Store should contain model with fields. I don't see it in your example

legaldiscovery
Aug 22, 2013, 10:38 AM
Store should contain model with fields. I don't see it in your example



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MultiComboBox.aspx.cs" Inherits="MultiComboBox" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!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 runat="server">
<title></title>
<script type="text/javascript">
var FromLoaded = function (store, records) {
if (Ext.getCmp('fpnlEdit') != undefined) {
if (records.length > 0) {
fpnlEdit.form.loadRecord(records[0]);
}
}
};
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="RMS" runat="server" Namespace="">
</ext:ResourceManager>
<ext:Store ID="fpnlEdit_Store" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="EtextValue">
</ext:ModelField>
</Fields>
</ext:Model>
</Model>
<Listeners>
<Load Fn="FromLoaded" />
</Listeners>
</ext:Store>
<ext:Viewport runat="server" ID="vpItemAdd" Layout="BorderLayout">
<Items>
<ext:FormPanel ID="fpnlEdit" runat="server" Border="false" ButtonAlign="Left" AutoScroll="true"
Title="Add Details" BodyPadding="50" Region="Center">
<Items>
<ext:FieldSet ID="FsEdit" runat="server" Border="false" Layout="FormLayout">
<Items>
<ext:MultiCombo ID="ddlMulti" FieldLabel="Items" runat="server" EmptyText="Select"
Name="EtextValue" SelectionMode="Selection">
<Items>
<ext:ListItem Text="Item 1" Value="1">
</ext:ListItem>
<ext:ListItem Text="Item 2" Value="2">
</ext:ListItem>
<ext:ListItem Text="Item 3" Value="3">
</ext:ListItem>
<ext:ListItem Text="Item 4" Value="4">
</ext:ListItem>
<ext:ListItem Text="Item 5" Value="5">
</ext:ListItem>
</Items>
</ext:MultiCombo>
</Items>
</ext:FieldSet>
</Items>
</ext:FormPanel>
</Items>
</ext:Viewport>
</form>
</body>
</html>


Server side Code as below:


DataTable dt = new DataTable();
dt.Columns.Add("EtextValue", typeof(string));
DataRow dr = dt.NewRow();
dr["EtextValue"] = "1,4";
dt.Rows.Add(dr);
fpnlEdit_Store.DataSource = dt;
fpnlEdit_Store.DataBind();


When i dr["EtextValue"] = "1" its work properly but when dr["EtextValue"] = "1,4" more than one value its create issue in selection
Please see the attached image.

Daniil
Aug 22, 2013, 3:59 PM
A MultiCombo's setValue expects an array of values, not a string.

You can do it this way:

records[0].data.EtextValue = records[0].data.EtextValue.split(",");
fpnlEdit.form.loadRecord(records[0]);