关闭

ligerUI智能提示

1712人阅读 评论(0) 收藏 举报
分类:

function GetUser() {

       var cache = {};

       $("#user").autocomplete({

           minLength: 1,

            //查找数据源事件

           source: function (request, response) {

                var term =request.term.trim();

                //request.field = $('#city').attr("value");

                if (term in cache) {

                   response(cache[term]);

                    return;

               }

                $.getJSON('@Url.Action("GetUser")', request,function (data, status, xhr) {

                   cache[term] = data;

                   response(data);

               });

            },

            //选择项事件

           select: function (event, ui) {

                var item =ui.item;

               $('#hid_user').attr("value", item.id);//对隐藏的"hid_user" 赋上下拉列表的选中项的id

            }

        });

    }

 

 

 

[HttpGet]

public ActionResult GetUser()

{

JavaScriptSerializer jss = new JavaScriptSerializer();

List<Model.Sys_Operator>sys_operator_list = new List<Model.Sys_Operator>();

BLL.Sys_Operator bll_sys_operator = new BLL.Sys_Operator();

string strwhere = "";

string t = Request["term"];

strwhere = "[Name] like  '%" + t + "%'"; //生成搜索条件

     sys_operator_list = bll_sys_operator.GetModelList(strwhere);

     var cl = sys_operator_list.Select(c => new

      {

label = c.Name,

value = c.Name,

id = c.Id

}).Take(15);

return Json(cl, JsonRequestBehavior.AllowGet);

}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:123877次
    • 积分:1653
    • 等级:
    • 排名:千里之外
    • 原创:52篇
    • 转载:9篇
    • 译文:0篇
    • 评论:4条
    最新评论