【问题标题】:showing data in jeasyui combobox在 jeasyui 组合框中显示数据
【发布时间】: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


    【解决方案1】:

    顺便说一句,你为什么要寻找困难的方式?

    只需查看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'">

    PHP get_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; 
    ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-04
      • 2012-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多