如何在文本框中显示一个值,点击"done"在sencha触摸中选择器字段中的按钮
How to display a value in a textfield on click of "done" button in picker field in sencha touch?
我正在尝试在sencha touch 2.1的文本字段中显示一个选择器字段的选定文本。我看不到任何错误在我的代码,但仍然不工作。下面是我的代码。请提供可行的解决方案。
{
xtype : 'textfield ',
id : 'PacingMode ',
style : 'background - color: #585858;',
top : '13.5%',
usePicker : true,
left : '20%',
width : '5%',
listeners : {
'focus' : function(a,e, eOpts) {
console.log("show caling");
document.activeElement.blur();
if (!this.picker) {
this.picker = Ext.Viewport.add({
xtype: 'picker',
id: 'pacingModePickerfield',
useTitles: true,
slots: [{
name: 'quantity',
title: 'Pacing Mode',
data: modelMgr.slotsdata1,
valueField: 'value',
}
],
doneButton: {
listeners: {
// when the done button is tapped, set the value
tap: function (button, event, eOpts) {
var sel = document.getElementById("pacingModePickerfield");
var text_value = sel.options[sel.selectedIndex].text;
Ext.getCmp('PacingMode').setValue(text_value);
}
}
}
});
}
this.picker.show();
},
change: function (a, e, newValue, eOpts) {
sendValueSetRequest(this.id);
},
}
您应该使用框架从选择器中获取值:
tap: function(button, event, eOpts) {
var val = Ext.getCmp("pacingModePickerfield").getValues().quantity;
Ext.getCmp('PacingMode').setValue(val);
}
试试这个
var thePicker = new Ext.Picker({
slots: [
{
name : 'limit_speed',
title: 'Speed',
data : [
{text: '50 KB/s', value: 50},
{text: '100 KB/s', value: 100},
{text: '200 KB/s', value: 200},
{text: '300 KB/s', value: 300}
]
}
],
listeners: {
change: function(picker, value, eOpts) {
alert(value.limit_speed);
}
}
});
这是我的工作代码:
doneButton : {
listeners : {
tap : function(button,event,eOpts) {
var selectedUpperSensorValue = Ext.getCmp('upperSensorPickerfield').getValue()['Upper Sensor'];
sendSetPendingRequest("UpperSensor",selectedUpperSensorValue);
}
}
}
相关文章:
- 铬:“;未捕获的语法错误:意外的标记:"
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- JS表单提交"无法使用Chrome数据保护程序加载此页面.尝试重新加载页面.调试信息:POST CISmtuK
- 检测电话窃听,即:<a href="电话:xxx">在UIWebview上
- 使用“+="操作人员
- //而不是在src=“”上使用http://"属性
- "未捕获的语法错误:意外的标记}"
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- "实例范围”;TypeScript类的getter/setter
- Javascript复选框函数:;缺少:在属性id之后"
- "“;变量未引用正确的对象
- "日期“;AJAX请求返回的类型值未定义
- 得到"TypeError:无法读取属性'filename'未定义的“;调用“npm start
- Soundcloud api"未捕获的类型错误:无法读取属性'uri'“未定义”;
- "工具提示"jQuery插件坏了
- "锻造;React中的表达式
- 图像可以从源<img src=""/>.TEXT可以在没有javascript的情况下从外部
- 如何提取“;href"最近列表项中的属性值
- CKEditor如何允许href="javascript:void(0)"在小部件中
- 插入“;img src"在javascript中