显示jeasyui组合框中的数据


showing data in jeasyui combobox

我有一个带有jeasui的组合框字段,我想验证数据。。但是数据不会出现在列表中。。

这是屏幕截图:

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
}
?>

有人能帮我吗。。谢谢你。

Btw为什么你在寻找困难的方法?

只需查看jeasyui combobox手动

示例:

HTML

    <input id="cc1" class="easyui-combobox" data-options="
            valueField: 'id',
            textField: 'text',
            url: 'get_data1.php',
            onSelect: function(rec){
                var url = 'get_data2.php?id='+rec.id;
                $('#cc2').combobox('reload', url);
            }">
    <input id="cc2" class="easyui-combobox" data-options="valueField:'id',textField:'text'">

PHPget_data2.php

<?php
$data="    [{
        "id":1,
        "text":"text1"
    },{
        "id":2,
        "text":"text2"
    },{
        "id":3,
        "text":"text3",
        "selected":true
    },{
        "id":4,
        "text":"text4"
    },{
        "id":5,
        "text":"text5"
    }]";
echo $data; 
?>