autocomplete 自动提示

来源:互联网 发布:淘宝乳胶床垫 编辑:程序博客网 时间:2024/05/29 19:02
<script language='javascript' src='${back.jsPath}/jquery.autocomplete.js'></script>

$(function() {            $("#studioName").autocomplete("${contextPath}/back/jiepan/studio/getStudio.htm", {                minChars: 1,                max: 20,                matchContains: true,                autoFill: false,                matchSubset:false,                dataType: 'json',                extraParams : {                    queryKeyword : function(){                        return encodeURI($("#studioName").val());                    }                },                parse: function(json) {                    $('#studioId').val("");                    data = json.data;                    return $.map(eval(data), function(row) {                        return {                            data: row,                            value: row.id,                            result: row.name                        }                    });                },                formatItem: function(data, i, n) {                    return "<table width='100%' bgcolor='#CCE58B' ><tr ><td  align='left' width='20%'>" + data.id + "</td><td align='left' >" + data.name + " </td></tr></table>";                },                formatResult: function(data,value) {                    return data.name;                }            }).result(function(event, data, formatted) { //回调                $('#studioId').val(data.id);                $("#studioName").val(data.name);            });        });



 @RequestMapping("getStudio")    public @ResponseBody    JsonWrapper<List<JiepanStudio>> getStudio(String queryKeyword, Model model) {        if(StringUtils.isEmpty(queryKeyword)){            return new JsonWrapper<List<JiepanStudio>>(false, "查询条件为空!");        }        try {            queryKeyword=URLDecoder.decode(queryKeyword,"UTF-8");        } catch (UnsupportedEncodingException e) {            LOG.error("转码异常!", e);        }        JiepanStudio search = new JiepanStudio();        search.setQueryKeyword(queryKeyword);        search.setDeleteFlag(Flag.FALSE.getValue());        search.setPageSize(20);        return new JsonWrapper<List<JiepanStudio>>(true, "查询成功!", jiepanStudioService.getStudio(search));    }

public List<JiepanStudio> getStudio(JiepanStudio search) {        return jiepanStudioDao.findPage(search).getResult();    }


阅读全文
0 0