2010-11-16 32 views
3

我想要得到以下内容以单行显示。我曾尝试使用样式浮动和显示。如何让ExtJS组合框与文本内联显示?

 
Show this input <input type="text" name="filterOp" id="filterOp"/> inline. 


<script type="text/javascript"> 
    new Ext.form.ComboBox({ 
     applyTo: 'filterOp', 
     triggerAction: 'all', 
     name: 'item', 
     mode: 'local', 
     lazyInit: true, 
     displayField: 'name', 
     valueField: 'id', 
     forceSelection: true, 
     typeAhead: true, 
     inputType:'text', 
     fieldLabel: 'Item selection', 
     style: "display: inline-block", 
     store: new Ext.data.JsonStore({ 
      autoLoad: true, 
      url: 'reporting/json_report_filter_operators.jsp', 
      root: 'rows', 
      fields:['id', 'name'] 
     }) 
    }) 

</script> 

回答

1

最简单的方法是覆盖页面上的样式。

首先,将您的段落包装在带有特殊ID的P标签中。

<p id="my-inline-override"> 
    Show this input <input type="text" name="filterOp" id="filterOp"/> inline. 
</p> 

然后你就可以添加一个CSS选择器的页面,确保通过Ext JS的添加DIV标签显示内嵌(注意,“X-表单域换行”是类插入DIV包装的,如果您使用Chrome开发人员工具浏览DOM,则可以看到这一点)。

<style> 
#my-inline-override div.x-form-field-wrap { 
    display: inline; 
} 
</style> 
0

对不起,您的问题有点混乱。你究竟想要在一条线上做什么?组合框?代码?组合框中的每个项目?如果它的每个项目只是扩大组合框,或使每个元素都有隐藏溢出和固定宽度。

+0

我想在浏览器中呈现时在同一行中看到“显示此输入”。 ComboxBox渲染时会生成一个div元素,它是一个块元素,将它渲染为一个新行。 – Artilheiro 2010-11-19 18:48:03