【发布时间】:2015-04-08 04:05:04
【问题描述】:
我有一个带有 jeasyui 的组合框字段,我想验证数据..但数据不会出现在列表中..
这是截图:
http://s.kaskus.id/images/2015/04/08/2192642_20150408103727.jpg
但是,当我在其上键入一个词来过滤列表时,它就起作用了! 例如有纽约和新泽西..我输入了它,列表被过滤了
这里又是截图:
http://s.kaskus.id/images/2015/04/08/2192642_20150408104053.jpg
这是代码..我从互联网上获取此代码,但该示例使用 json 获取数据,同时我使用指向另一个文件的链接获取数据。
function cmdArea($name,$caption)
{
?>
<tr>
<td><?php getCaption($caption);?> :</td>
<td>
<input class="easyui-combobox"
id="<?php echo $name;?>"
name="<?php echo $name;?>"
data-options="
method:'post',
mode:'remote',
valueField:'id',
textField:'area_name',
panelHeight:'auto',panelHeight:100,width:150, forceSelection:true"
disabled=true>
</input>
<script>
$.extend($.fn.validatebox.defaults.rules,{
exists:{
validator:function(value,param){
var cc = $(param[0]);
var v = cc.combobox('getValue');
var rows = cc.combobox('getData');
for(var i=0; i<rows.length; i++){
if (rows[i].id == v){return true}
}
return false;
},
message:'The entered value does not exists.'
}
});
$(function () {
$('#harea').combobox({
url: 'services/runCRUD.php?func=datasource&lookup=mst/area&pk=<?php echo "area_code"; ?>&sk=<?php echo "area_name"; ?>&order=area_name', // <-- here is my data, the example was a json data then i tried to change with mine but not working
panelHeight: 'auto',
selectOnNavigation: false,
valueField: 'id',
textField: 'text',
editable: true,
required: true,
validType: 'exists["#harea"]',
onLoadSuccess: function () { },
filter: function (q, row) {
return row.text.toLowerCase().indexOf(q.toLowerCase()) == 0;
},
});
$('#harea').combobox('setValue','1');
$('#harea').combobox('validate')
alert($('#harea').combobox('isValid'));
});
</script>
</td>
</tr>
<?php
}
?>
谁能帮帮我.. 并感谢之前。
【问题讨论】:
标签: php jquery combobox jquery-easyui