[CLOSED] MultiCombox to display custom Text

  1. #1

    [CLOSED] MultiCombox to display custom Text

    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
    Last edited by Daniil; Jul 23, 2013 at 5:15 AM. Reason: [CLOSED]
  2. #2
    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>
  3. #3
    Quote Originally Posted by Daniil View Post
    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

Similar Threads

  1. [CLOSED] making text area to display html formated text
    By SymSure in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 19, 2012, 5:07 PM
  2. [CLOSED] Question about custom display by condition.
    By rosua in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 30, 2012, 10:36 AM
  3. [CLOSED] Custom control : Problem of display.
    By ddslogistics in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 14, 2010, 5:40 PM
  4. Replies: 1
    Last Post: Nov 09, 2010, 3:30 PM
  5. Replies: 1
    Last Post: Apr 30, 2010, 3:11 PM

Posting Permissions