[CLOSED] Displaying <, >, [, ] in ListItem

  1. #1

    [CLOSED] Displaying <, >, [, ] in ListItem

    I have a multicombo of which I need to add a list item containing either <, > or [, ]. When using <, >, the text does not display in the drop down unless it is encoded, but displays correctly in the textbox when selected. If I use [, ], I am not able to select the item. Any way to have it display correctly in both places & be selectable?

    Thank you.
    Last edited by Daniil; Dec 22, 2011 at 3:34 AM. Reason: [CLOSED]
  2. #2
  3. #3
    So now I can get the text to display correctly, however, the checkboxes are not appearing:

    <ext:MultiCombo ID="cboType" runat="server" Width="200" FieldLabel="Type" LabelWidth="45">
    <Template runat="server">
    <Html>
    <tpl for=".">
    <div class="x-combo-list-item">{text:htmlEncode}</div>
    </tpl>
    </Html>
    </Template>
    </ext:MultiCombo>
  4. #4
    Well, MultiCombo uses its own internal template which is much more complicated.

    Here it is:
    this.tpl = '<tpl for="."><div class="x-combo-list-item {[this.getItemClass()]}">' +
        '<img src="' + Ext.BLANK_IMAGE_URL + '" class="{[this.getImgClass(values)]}" />' +
        '<div class="x-mcombo-text">{' + this.displayField + ':htmlEncode}</div></div></tpl>';
    Generally, you can set up that template using the MultiCombo's Template property as you've already tried or override the initComponent function.

    Example
    <script type="text/javascript">
        var myInitComponent = function () {
            this.editable = false;
    
            if (!this.tpl) {
                this.tpl = '<tpl for="."><div class="x-combo-list-item {[this.getItemClass()]}">' +
                    '<img src="' + Ext.BLANK_IMAGE_URL + '" class="{[this.getImgClass(values)]}" />' +
                    '<div class="x-mcombo-text">{' + this.displayField + ':htmlEncode}</div></div></tpl>';
    
                this.tpl = new Ext.XTemplate(this.tpl, {
                    getItemClass : (function () {
                        if (this.selectionMode === "selection") {
                            return "x-mcombo-nimg-item";
                        }
    
                        return "x-mcombo-img-item";
    
                    }).createDelegate(this),
    
                    getImgClass : (function (values) {
                        if (this.selectionMode === "selection") {
                            return "";
                        }
    
                        var found = false;
    
                        Ext.each(this.checkedRecords, function (record) {
                            // do not replace == by ===
                            if (values[this.valueField] == record.get(this.valueField)) {
                                found = true;
                                return false;
                            }
                        }, this);
    
                        return found ? "x-grid3-check-col-on" : "x-grid3-check-col";
                    }).createDelegate(this, [], true)
                });
            } 
    
            this.checkedRecords = [];
    
            Ext.net.MultiCombo.superclass.initComponent.apply(this, arguments);
            
            if (this.selectionPredefined) {
                this.initSelection(this.selectionPredefined);
            }
    
            this.on("beforequery", this.onBeforeQuery);
        };
    </script>
    
    ************************
    
    <ext:MultiCombo runat="server">
        <CustomConfig>
            <ext:ConfigItem Name="initComponent" Value="myInitComponent" Mode="Raw" />
        </CustomConfig>    
    </ext:MultiCombo>

Similar Threads

  1. [CLOSED] ComboBox empty ListItem
    By methode in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 18, 2013, 4:01 AM
  2. [CLOSED] Add listitem to multiselect use javascript.
    By gs_user in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 13, 2012, 7:49 AM
  3. [CLOSED] [1.0]Set combo listItem icon at runtime
    By edigital in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 03, 2010, 11:12 AM
  4. <ext:ListItem don't appears in my form???
    By carlosmupe in forum 1.x Help
    Replies: 4
    Last Post: Dec 30, 2009, 3:56 PM
  5. ComboBox ListItem Selected
    By Timothy in forum Bugs
    Replies: 1
    Last Post: Aug 22, 2008, 2:51 PM

Tags for this Thread

Posting Permissions