PDA

View Full Version : [CLOSED] Problem in multicombobx



feanor91
Apr 23, 2012, 1:19 PM
Hello

Following the problem in this thread: http://forums.ext.net/showthread.php?18544-Proble-with-combobox-in-window

in that code:



<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>


<script runat="server">

protected void Page_Load(object sender,EventArgs e)
{
// Load the data into the Store and DataBind.
this.stoChartsName.DataSource = this.stoChartsNameData;
this.stoChartsName.DataBind();
this.stoChartsTemplate.DataSource = this.stoChartsTemplateData;
this.stoChartsTemplate.DataBind();
}

private object[] stoChartsNameData
{
get
{
return new object[]
{
new object[] {12,"Abandon rate"},
new object[] {11,"Activity time split"},
new object[] {16,"Average handle time"},
new object[] {17,"Average seconds to answer"},
new object[] {22,"Back order value"},
new object[] {14,"Cost per contact"},
new object[] {24,"Costs (Transport & Waehouse)"},
new object[] {20,"Delivery attempt"},
new object[] {3,"ETFQ"},
new object[] {2,"ETTR"},
new object[] {13,"First call resolution"},
new object[] {23,"Inventory days"},
new object[] {25,"Inventory value"},
new object[] {15,"Occupancy"},
new object[] {6,"OOBF"},
new object[] {18,"Orders"},
new object[] {19,"Parcels shipped"},
new object[] {21,"Product driving back order"},
new object[] {9,"Product split"},
new object[] {1,"Repair by month"},
new object[] {4,"Repair cost"},
new object[] {5,"Stock out"},
new object[] {10,"Type of repair split"},
new object[] {7,"User requests calls & mail"},
new object[] {8,"User requests letters & fax"}
};
}
}


private object[] stoChartsTemplateData
{
get
{
return new object[]
{
new object[] {1,"Service","Activity time split,ETFQ,ETTR,OOBF,Product split,Repair by month,Repair cost,Stock out,Type of repair split,User requests calls & mail,User requests letters & fax","11,3,2,6,9,1,4,5,10,7,8",false,20},
new object[] {2,"Logistic","Back order value,Costs (Transport & Warehouse),Delivery attempt,Inventory days,Inventory value,Orders,Parcels shipped,Product driving back order","22,24,20,23,25,18,19,21",false,20},
new object[] {3,"Service & Logistic","Activity time split,ETFQ,ETTR,OOBF,Product split,Repair by month,Repair cost,Stock out,Type of repair split,User requests calls & mail,User requests letters & fax,Back order value,Costs (Transport & Waehouse),Delivery attempt,Inventory days,Inventory value,Orders,Parcels shipped,Product driving back order","11,3,2,6,9,1,4,5,10,7,8,22,24,20,23,25,18,19,21",false,20},
new object[] {4,"Call center","Abandon rate,Average handle time,Average seconds to answer,Cost per contact,First call resolution,Occupancy","12,16,17,14,13,15",false,20},
new object[] {6,"All charts","Abandon rate,Activity time split,Average handle time,Average seconds to answer,Back order value,Cost per contact,Costs (Transport & Warehouse),Delivery attempt,ETFQ,ETTR,First call resolution,Inventory days,Inventory value,Occupancy,OOBF,Orders,Parcels shipped,Product driving back order,Product split,Repair by month,Repair cost,Stock out,Type of repair split,User requests calls & mail,User requests letters & fax","12,11,16,17,22,14,24,20,3,2,13,23,25,15,6,18,19,21 ,9,1,4,5,10,7,8",false,20}
};
}
}

</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 runat="server">
<title></title>

<script type="text/javascript">
var cancelAddRecord = function ()
{

//var gridName = returnName( this );
var grid = this.grid;

grid.editingPlugin.cancelEdit();
var s = grid.getSelectionModel().getSelection();

for ( var i = 0, r; r = s[i]; i++ )
{
grid.store.remove( r );
};
grid.store.reload();
};

var addNewRecord = function ()
{


var gridName = this.id.substr( 6 );
var grid = Ext.getCmp( "grd" + gridName );

grid.editingPlugin.cancelEdit();

switch ( gridName )
{

case "Template":
grid.store.insert( 0, {
STR_Template: "New template name",
STR_ChartsInTemplate: "",
BOOL_Private: false,
INT_idUser: 0
} );
break;

}

grid.getView().refresh();
grid.editingPlugin.startEdit( 0, 0 );
};

RendercboCharts = function ( value, p, record )
{
return record.data.STR_ChartsInTemplateName;
};

</script>

</head>


<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" RethrowAjaxExceptions="True"></ext:ResourceManager>

<ext:Store ID="stoChartsName" runat="server" AutoLoad="True">
<Reader>
<ext:ArrayReader />
</Reader>
<Model>
<ext:Model ID="Model2" runat="server">
<Fields>
<ext:ModelField Name="INT_idCharts" Type="Int" />
<ext:ModelField Name="STR_FriendlyName" type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>

<ext:Desktop
ID="MyDesktop"
runat="server">
<DesktopConfig ID="DesktopConfig1" runat="server">
</DesktopConfig>

<Modules>
<%-- Template window--%>
<ext:DesktopModule ModuleID="Template">
<Window>
<ext:Window
runat="server"
Icon="Table"
Width="800"
Height="380"
Layout="Fit"
Hidden="True"
ExpandOnShow="True"
MinHeight="100"
MinWidth="100"
Maximizable="False"
Resizable="False"
TitleCollapse="True"
Title="Chart template definition"
Collapsible="True">
<Items>
<ext:GridPanel
ID="grdTemplate"
runat="server"
Cls="x-grid-custom"
AutoScroll="False"
ColumnLines="True" >
<Store>
<ext:Store ID="stoChartsTemplate" runat="server" WarningOnDirty="False">
<Reader>
<ext:ArrayReader />
</Reader>
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="INT_idTemplate" />
<ext:ModelField Name="STR_Template" />
<ext:ModelField Name="STR_ChartsInTemplateName" />
<ext:ModelField Name="STR_ChartsInTemplateValue" />
<ext:ModelField Name="BOOL_Private" />
<ext:ModelField Name="INT_idUser" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel6" runat="server">
<Columns>
<ext:Column Runat="server" ID="idTemplate" DataIndex="INT_idTemplate" MenuDisabled="True" Fixed="True" Groupable="False" Hideable="False" Resizable="False" Sortable="False" Width="30" Text="ID" Hidden="True">
</ext:Column>
<ext:Column Runat="server" Flex="1" ID="Template" DataIndex="STR_Template" MenuDisabled="True" Fixed="True" Groupable="False" Hideable="False" Resizable="False" Sortable="true" MinWidth="200" Text="Template">
<Editor>
<ext:TextField runat="server"></ext:TextField>
</Editor>
</ext:Column>
<ext:Column Runat="server" ID="ChartsInTemplate" DataIndex="STR_ChartsInTemplateValue" MenuDisabled="True" Fixed="True" Groupable="False" Hideable="False" Resizable="False" Sortable="true" Width="500" Text="Charts in template">
<Editor>
<ext:MultiCombo
ID="MultiCombo1"
Enabled="true"
runat="server"
Editable="false"
Width="500"
StoreID="stoChartsName"
AllowBlank="False"
EmptyText="Please choose a value..."
DisplayField="STR_FriendlyName"
ValueField="INT_idCharts">
<ListConfig ID="ListConfig33" runat="server" Cls="top-list">
</ListConfig>
</ext:MultiCombo>
</Editor>
<Renderer Fn="RendercboCharts" />
</ext:Column>
<ext:BooleanColumn
runat="server"
ID="Private"
DataIndex="BOOL_Private"
Width="200"
MenuDisabled="True"
Resizable="False"
Sortable="False"
Text="Template is Private"
TrueText="Yes"
FalseText="No" Fixed="True">
<Editor>
<ext:Checkbox ID="Changebox2" runat="server"></ext:Checkbox>
</Editor>
</ext:BooleanColumn >
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel6" runat="server">
</ext:RowSelectionModel>
</SelectionModel>
<TopBar>
<ext:Toolbar ID="Toolbar3" runat="server">
<Items>
<ext:Button ID="btnAddTemplate" runat="server" Text="Add a template" Icon="Add">
<Listeners>
<Click Fn="addNewRecord" />
</Listeners>
</ext:Button>
<ext:Button ID="btnDelTemplate" runat="server" Text="Remove a template" Icon="Delete">
<%-- <DirectEvents>
<Click OnEvent="btnDelTemplate_Click">
<ExtraParams>
<ext:Parameter Name="data" Value="#{grdTemplate}.getRowsValues({selectedOnly : true})" Mode="Raw" Encode="true"></ext:Parameter>
</ExtraParams>
</Click>
</DirectEvents> --%>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<View>
<ext:GridView ID="GridView12" runat="server" />
</View>
<Plugins>
<ext:RowEditing ID="RowEditing5" runat="server" >
<%-- <DirectEvents>
<ValidateEdit OnEvent="UpdateTemplate">
<ExtraParams>
<ext:Parameter Name="data" Value="e.record.data" Mode="raw" Encode="true" ></ext:Parameter>
</ExtraParams>
</ValidateEdit>
</DirectEvents>--%>
<Listeners>
<CancelEdit Fn="cancelAddRecord" />
</Listeners>
</ext:RowEditing>
</Plugins>
</ext:GridPanel>
</Items>
</ext:Window>
</Window>
</ext:DesktopModule>


</Modules>

<StartMenu Height="300" Title="Start Here" runat="server" HideTools="True">
<MenuItems>
<ext:MenuItem Text="Tools" Icon="Wrench">
<Menu>
<ext:Menu ID="mnuTemplate" runat="server">
<Items>
<ext:MenuItem Text="Charts template" Icon="Eye">
<Listeners>
<Click Handler="#{MyDesktop}.getModule('Template').createWindow();" />
</Listeners>
</ext:MenuItem>
</Items>
</ext:Menu>
</Menu>
</ext:MenuItem>
</MenuItems>
</StartMenu>
<TaskBar runat="server" TrayWidth="50">
<TrayClock runat="server" ></TrayClock>
</TaskBar>
</ext:Desktop>

</form>
</body>
</html>



When editing the multi combobox, item in the combo was not selected in the dropdown and when trigering the box, the displayfield change to the valuefield.

What's wrong?

Daniil
Apr 23, 2012, 2:51 PM
Hi,

Please look at the following example for Ext.NET v1.
http://forums.ext.net/showthread.php?10496&p=42128&viewfull=1#post42128

It demonstrates what you should change.

Briefly, you should bind a list of values - not just a string and implement a respective Renderer.

feanor91
Apr 23, 2012, 2:56 PM
OK, I will try that.

Meanwhile in V1, All works fine with my method.

Edit :

I implement that code :



RendercboCharts = function ( value, p, record )
{
var myRenderer = function ( value )
{
var values = value.split( cboMultiChartsTemplate.delimiter ),
value = [];
if ( values == "" )
{
return "";
}
for ( var i = 0; i < values.length; i++ )
{
var index = cboMultiChartsTemplate.store.findExact( "value", values[i] ),
record = cboMultiChartsTemplate.store.getAt( index );
value.push( record.get( cboMultiChartsTemplate.displayField ) );
}
return value.join( cboMultiChartsTemplate.delimiter ); ;
};
};


And now, the behaviour is worst, I have nothing rendered and when I click to edit, I have values in the field and nothing checked in the dropdownlist in which I can't select.

(BTW, i cnge name of my combo from default to cboMultiChartsTemplate)

I update the code in the other thread

Edit: I will have to go deeper in the code, for now, I have nothing displayed in the grid (???).

Daniil
Apr 23, 2012, 6:58 PM
MultiCombo is an inheritor of ComboBox. ComboBox has been much refactored in v2. Therefore your v1 code has stopped working.

Now MultiCombo should get an array of values, not just a string.

I was able to get it working changing a data which you bind to the "STR_ChartsInTemplateValue" ModelField.

I'm talking about:

"11,3,2,6,9,1,4,5,10,7,8"

Please replace it with

new int[] { 11, 3, 2, 6, 9, 1, 4, 5, 10, 7, 8 }

feanor91
Apr 24, 2012, 7:33 AM
MultiCombo is an inheritor of ComboBox. ComboBox has been much refactored in v2. Therefore your v1 code has stopped working.

Now MultiCombo should get an array of values, not just a string.

I was able to get it working changing a data which you bind to the "STR_ChartsInTemplateValue" ModelField.

I'm talking about:

"11,3,2,6,9,1,4,5,10,7,8"

Please replace it with

new int[] { 11, 3, 2, 6, 9, 1, 4, 5, 10, 7, 8 }

Perfect, it works. You can close thread, thanks.

BTW, my renderer works too. I update code in the other thread to reflect the change. We move on, it's good.