PDA

View Full Version : [CLOSED] MultiCombox to display custom Text



PriceRightHTML5team
Jul 18, 2013, 2:05 PM
Hi Ext.Net Team,

I have a scenario, when we select 2 items from the multi combo box it displays 1st item text, 2nd item text

e.g:
t1,t2 on the combox.

what i need is if 2 items are selected i need to change that text as "Multi-selection"

how can i do that on client side.

Thanks in advance

Daniil
Jul 18, 2013, 5:10 PM
Hi @PriceRightHTML5team,

I would try to override a MultiCombo's getDisplayValue.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store store = this.MultiCombo1.GetStore();
store.DataSource = new object[]
{
new object[] { "1", "Item 1" },
new object[] { "2", "Item 2" },
new object[] { "3", "Item 3" }
};
}
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>

<script>
var myGetDisplayValue = function () {
var value;

if (this.valueModels.length > 1) {
value = "Multi-selection";
} else {
value = this.displayTpl.apply(this.displayTplData);
}

return this.wrapBySquareBrackets ? "[" + value + "]" : value;
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:MultiCombo
ID="MultiCombo1"
runat="server"
DisplayField="text"
ValueField="value">
<CustomConfig>
<ext:ConfigItem Name="getDisplayValue" Value="myGetDisplayValue" Mode="Raw" />
</CustomConfig>
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="value" />
<ext:ModelField Name="text" />
</Fields>
</ext:Model>
</Model>
<Reader>
<ext:ArrayReader />
</Reader>
</ext:Store>
</Store>
</ext:MultiCombo>
</form>
</body>
</html>

PriceRightHTML5team
Jul 23, 2013, 5:52 AM
Hi @PriceRightHTML5team,

I would try to override a MultiCombo's getDisplayValue.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store store = this.MultiCombo1.GetStore();
store.DataSource = new object[]
{
new object[] { "1", "Item 1" },
new object[] { "2", "Item 2" },
new object[] { "3", "Item 3" }
};
}
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>

<script>
var myGetDisplayValue = function () {
var value;

if (this.valueModels.length > 1) {
value = "Multi-selection";
} else {
value = this.displayTpl.apply(this.displayTplData);
}

return this.wrapBySquareBrackets ? "[" + value + "]" : value;
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:MultiCombo
ID="MultiCombo1"
runat="server"
DisplayField="text"
ValueField="value">
<CustomConfig>
<ext:ConfigItem Name="getDisplayValue" Value="myGetDisplayValue" Mode="Raw" />
</CustomConfig>
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="value" />
<ext:ModelField Name="text" />
</Fields>
</ext:Model>
</Model>
<Reader>
<ext:ArrayReader />
</Reader>
</ext:Store>
</Store>
</ext:MultiCombo>
</form>
</body>
</html>


Thank you Daniil .Its working