Ajax-combobox动态绑定数据
来源:互联网 发布:服务器 定时关机 软件 编辑:程序博客网 时间:2024/06/01 12:20
分享一个常用的知识点,最近在项目中用到了,弄这块的时候废了不少劲。
项目中用到的控件是easyui-combobox,下拉框中加载数据库中的数据。
下面是一个简单的例子:
Html
仓库:<input id="select_storage" class="easyui-combobox" data-options="editable:true,valueField:'id',textField:'text',width:80"/>
Js
//窗体加载时执行$(document).ready(function () { //获取所有仓库名称 $.ajax({ type: "GET", url: "/WarehousingLog/QueryAllStorageName", dataType: "json", success: function (data) { //测试是否有数据传入 if (data.length >= 0) { alert("仓库有数据!"); //定义一个变量存放数据 var data1 = [{ 'text': '', 'id': '' }]; //循环,向变量里添加数据 for (var i = 0; i < data.length; i++) { data1.push({ "text": data[i].StorageName, "id": data[i].StorageID });//text为元素的文本内容,id为该元素的value值 } //在下拉框中加载变量中的数据 $('#select_storage').combobox("loadData", data1); // .datafrid为table加载 } }, error: function (data) { alert('系统出错了,请联系管理员!'); } })})//窗体加载
Controller
public JsonResult QueryAllStorageName() { WarehousingLogBLL item = new WarehousingLogBLL(); List<T_Storage> list = storage.QueryAllStorage (); return Json (list,JsonRequestBehavior.AllowGet ); }
阅读全文
0 0
- Ajax-combobox动态绑定数据
- ComboBox 动态绑定数据
- easyui combobox动态绑定数据
- ComboBox 经验总结[动态绑定数据之后,静态添加一条数据]
- 动态绑定combobox
- # winform comboBox动态下拉列表,comboBox动态绑定数据库里的数据
- c# combobox 数据绑定
- ComboBox 数据绑定问题
- ComboBox/ListBox绑定数据
- WPF 数据绑定 combobox
- ComboBox数据的绑定
- Combobox 控件绑定数据
- delphi绑定ComboBox数据
- AJAX 动态加载后台数据 绑定select
- easyUI-combobox 动态绑定数据源
- combobox使用--绑定数据设置
- [VB.NET]combobox数据绑定
- c# 中combobox绑定数据
- java客户端访问集群时用户权限报错:rg.apache.hadoop.security.AccessControlException:
- Python 窗体(tkinter)列表框(Listbox)
- Java 基础(3) —— this 的用法
- linux网络API细节
- makefile
- Ajax-combobox动态绑定数据
- Modbus协议学习(四)
- UVA 11082 Matrix Decompressing——抽象建图+最大流
- 英语学习记录
- 【Spring】手动实现AOP编程(十一)
- 金额转换
- LAMP环境搭建Wordpress
- 训练总结 10.8
- Hadoop基于Linux-CentOS7安装-初识Linux