EasyUI Combobox 组合框

默认选择第一项,加请选择,取值问题

<input class="easyui-combobox" id="ddlWHS" name="ddlWHS" />


 //combox默认选择第一个
                        $(function () {
                            $('#ddlWHS').combobox({
                                url: "../../HR/attType/list_attType.ashx?type=Bindddl",
                                valueField: 'WorkingHour_beginTime',
                                textField: 'WorkingHour_name',
                                editable: false,
                                onLoadSuccess: function (data) {
                                    var data = $('#ddlWHS').combobox('getData');
                                    if (data.length > 0) {
                                        $("#ddlWHS").combobox('select', data[0].WorkingHour_beginTime);
                                    }
                                }
                            });
                        });

                       //    combox加请选择 
                        $(function () {
                            $('#ddlWHS').combobox({
                                url: "../../HR/attType/list_attType.ashx?type=Bindddl",
                                valueField: 'WorkingHour_beginTime',
                                textField: 'WorkingHour_name',
                                editable: false,
                                //返回要显示的过滤数据
                                loadFilter: function (data) {
                                    var o = [{ 'WorkingHour_beginTime': '0', 'WorkingHour_name': '--请选择--'}];
                                    return o.concat(data);
                                },
                                //当远程数据加载成功时触发 
                                onLoadSuccess: function (data) {
                                    var data = $('#ddlWHS').combobox('getData');
                                    if (data.length > 0) {
                                        $("#ddlWHS").combobox('select', data[0].WorkingHour_beginTime);
                                    }
                                },
                                onSelect: function (record) {
                                  //获取values
                                   alert($("#ddlWHS").combobox("getValues"));
                                  // 获取text
                                   alert($("#ddlWHS").combobox("getText"));
                                }

                            });
                        });

 

posted @ 2016-07-11 11:07  来自潘大大  阅读(1768)  评论(0编辑  收藏  举报