0

有没有办法设置组合框项目的最后一项(或最后两项)的颜色,我尝试使用 TPL 但没有用。这是在我更新之前定义的 XTeplate 的 TPL 定义。非常感谢。

var resultTplHesap103Ekod = new Ext.XTemplate(
 '<tpl for="."><div class="x-combo-list-item">',
 '<h3><span> {val}  </h3>',
 '<span style="color:blue"> {dsc}  </span>', '</div></tpl>'
);

来自@MMT,

我改变了这样的代码。

var resultTplHesap360Ekod = new Ext.XTemplate(
        '<tpl for=".">',
            '<tpl if="(xindex ) &gt; (xcount-1)">',
               '<tpl>',
                    '<div class="x-combo-list-item">',
                    '<h3> {val}  </h3>',
                    '<span style="color:red"> {dsc}  </span>', 
                    '</div>',
               '</tpl>',
            '</tpl>',

            '<tpl if="(xindex ) &lt; (xcount-2)">',
               '<tpl>',
                    '<div class="x-combo-list-item">',
                    '<h3> {val}  </h3>',
                    '<span style="color:blue"> {dsc}  </span>', 
                    '</div>',
               '</tpl>',
            '</tpl>',
        '</tpl>'
    );

var comboHsp360EkodHarcama = new Ext.form.ComboBox({
            fieldLabel : '',
            labelSeparator : '',
            triggerAction : 'all',
            mode : 'local',
            store : storeHesapTasinirHeskod360,
            displayField : 'dsc',
            valueField : 'val',
            emptyText : 'Damga Vergisi Türü',
            forceSelection : true,
            hidden : true,
            forceSelection : true,
            tpl : resultTplHesap360Ekod,
            width : 300,
            listClass : 'x-combo-list-item'
        });

var storeHesapTasinirHeskod360 = new Ext.data.JsonStore({
            url : '../gen/hesapTasinir.ajax',
            root : 'list',
            fields : ['dsc', 'val']
        });

现在代码正在运行,非常感谢@MMT,最后一项(现在)是红色的,这对我很重要,但现在我遇到了另一个问题。当我选择最后一个 RED 项目时,它在顶部 ob 框的文本字段中显示为黑色。你能帮我让它保持红色吗?问候。

4

1 回答 1

1

尝试这个

    var tpl = new Ext.XTemplate(
        '<tpl for=".">',
            '<tpl if="(xindex ) &gt; (xcount-2)">',
               '<tpl>',
                    '<div class="x-combo-list-item">',
                    '<h3> {value}  </h3>',
                    '<span style="color:red"> {name}  </span>', 
                    '</div>',
               '</tpl>',
            '</tpl>',

            '<tpl if="(xindex ) &lt; (xcount-2)">',
               '<tpl>',
                    '<div class="x-combo-list-item">',
                    '<h3> {value}  </h3>',
                    '<span style="color:blue"> {name}  </span>', 
                    '</div>',
               '</tpl>',
            '</tpl>',

        '</tpl>'
    );
于 2013-08-15T11:39:05.150 回答