<select id="prd_tech_for_load" class="selectable" style="width:180px;">
</select>

不需要分页时,直接在select内添加option列表

如果要分页的话

$(function () {
$("#prd_tech_for_load").select2();
var sel_tech = $("#prd_tech_for_load").select2({
placeholder: abp.localization.values['ICT'].SelTechReq,
ajax: {
url: '../PDE/GetProductList',
dataType: 'json',
delay: 250,
data: function (params) {
return {
queryText: params.term // search term
};
},
processResults: function (data, params) {
params.page = params.page || 1;
return {
results: data.result.data,
pagination: {
more: 1 < data.totalPages
}
};
},
cache: true
},
//disabled: true,
escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
minimumInputLength: 0,
templateResult: function (item) { // 显示查询结果
var display = '';
if (item.technology != null) display += item.technology;
//if (item.customerName != null) display += '(' + item.customerName + ')';
return display;
},
templateSelection: function (item) { // 显示选中的对象
var display = '';
if (item.technology != null) display += item.technology;
if (item.customerName != null) display += '(' + item.customerName + ')';
return display || item.text;
}
}); sel_tech.on("select2:select", function (e) {
defaultVue.ProductID = e.params.data.productId;
});
});

这里要注意的一个问题是,后台返回的数据列表必须含有id这个字段,不然会出现问题,一直不能选中数据。

这个不知道的人,被坑死了!

select2插件的使用的更多相关文章

  1. select2插件

    引入select2插件<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min. ...

  2. 基于Metronic的Bootstrap开发框架经验总结(3)--下拉列表Select2插件的使用

    在上篇<基于Metronic的Bootstrap开发框架经验总结(2)--列表分页处理和插件JSTree的使用>介绍了数据的分页处理,使用了Bootstrap Paginator插件,另外 ...

  3. Metronic_下拉列表Select2插件的使用

    这个插件是基于Select的扩展插件,能够提供更加丰富的功能和用户体验,它的github官网地址为:https://select2.github.io/,具体的使用案例,可以参考地址:https:// ...

  4. jQuery的下拉选select2插件用法

    1转自:https://www.jb51.net/article/95561.htm 用了这么久的Select2插件,也该写篇文章总结总结.当初感觉Select2不是特别好用,但又找不到比它更好的下拉 ...

  5. select2插件用法

    1.修改默认查询方法,使其可以根据value查询 this.element.select2({ allowClear: true, matcher: function (term, text, ele ...

  6. Select2插件的隐藏、设置宽度

    <select id="selPrinvice" class="Select2 select2-hidden-accessible" style=&quo ...

  7. 01:jQuery的下拉选select2插件用法

    1.1 select2插件基本使用 1.下载select2插件 1. 下载地址:https://github.com/select2/select2 2.官网地址:https://select2.or ...

  8. select2插件使用小记2 - 多选联动 - 笔记

    这是select2插件使用的第二篇,可参考第一篇 select2插件使用小记.上一篇主要是关于基本的使用,这篇主要是关于多选,及联动的.侧重点不同. 效果图如下: 遵从W3C标准:结构.样式.行为.以 ...

  9. 在select2插件中append下拉选,点击没反应的解决

    今天前端大佬帮我解决了一个棘手的问题:克隆了已有系统的网页,尝试把复制下来的html改造成jsp.基本功能正常,然而点击新增按钮,出来的行无法点击下拉选,控制台也没报错. 项目用的是jeesite2. ...

  10. select2 插件

    官网:http://select2.github.io/ Select2是基于jQuery的一个插件,没有引用jQuery,是没有效果的   1.在实现给select2添加placeholder效果的 ...

随机推荐

  1. Mac下android_sdk配置环境变量

    1.启动Terminal终端工具 2.输入cd ~/ 进入当前用户的home目录 3. 创建: touch .bash_profile 4.打开并编辑: open .bash_profile 5.在文 ...

  2. Maven with Multi-module

    Well, A project made of multi modules. For example, the hongten-security project, the structure of t ...

  3. C#.NET Form设置/取消开机自动运行,判断程序是否已经设置成开机自动启动(转载)

    #region//开机自动运行        private void CB_Auto_CheckedChanged(object sender, EventArgs e)        {//CB_ ...

  4. KeyValue与KeyData与KeyCode区别(转)

    KeyValue与KeyData与KeyCode区别(转) KeyPress事件 KeyPressEventArgs参数 Handled /是否处理过KeyPress事件 KeyChar //按下的键 ...

  5. SQL 中怎么查询一个数据库中一共有多少个表

    用户表:select count(*) 总表数 from sysobjects where xtype='u' 总表数:select count(*) 总表数 from sysobject s whe ...

  6. Func<T, TResult> Delegate

    public delegate TResult Func<in T, out TResult>( T arg ) http://msdn.microsoft.com/en-us/libra ...

  7. java script小结

    javascript是一种嵌入在网页里的程序段,是一种解释性语言,只能被浏览器解释执行.出于安全性的考虑,增加了javascript的限制,增强了客户端交互功能. JavaScript的作用: 1.增 ...

  8. js如何使得新打开的窗口居中

    <a href="#" class="blue" onclick="window.open('/Content/service.html', ' ...

  9. 手机访问pc网站自动跳转手机端网站代码

    <SCRIPT LANGUAGE="JavaScript">function mobile_device_detect(url){        var thisOS= ...

  10. [CareerCup] 18.11 Maximum Subsquare 最大子方形

    18.11 Imagine you have a square matrix, where each cell (pixel) is either black or white. Design an ...