//datagrid初始化 $('#dg').datagrid({ nowrap: false, striped: true, border: false, collapsible: false, //是否可折叠的 fit: true, //自动大小 fitColumns: false, //url: "", datatype: 'json', remoteSort: false, idField: 'detail_id', singleSelect: true, //是否单选 rownumbers: true, //行号 loadMsg: '数据加载中请稍后……', columns: [[ { field: 'id', hidden: 'hidden' }, { field: 'line_number', hidden: 'hidden', title: '编号', 40, align: 'center' }, { field: 'goods_class', title: '物品分类', 200, align: 'center', editor: { type: 'combobox', options: { valueField: 'id', textField: 'text', url: '', required: true, editable: true } }, formatter: format_goods_class }, { field: 'goods_short_name', title: '物品简称', 100, align: 'center', editor: { type: 'textbox', options: { required: true, editable: true } } }, { field: 'goods_full_name', title: '物品名称/规格描述', 180, align: 'center', editor: { type: 'textbox', options: { required: true, editable: true } } }, { field: 'product_line', title: 'Product Line', 100, align: 'center', editor: { type: 'combobox', options: { valueField: 'dictionary_name', textField: 'dictionary_name', url: '', required: true, editable: false } } }, { field: 'qty', title: '请购数量', 80, align: 'center', editor: { type: 'numberbox', options: { min: 0.01, precision: 2, required: true, editable: true } } }, { field: 'unit', title: '单位', 80, align: 'center', editor: { type: 'combobox', options: { valueField: 'id', textField: 'text',
//列数据列表 data: unit_list, required: true, editable: true } } }]], onBeginEdit: function (index, row) { //获取单位的编辑器 var unitditor = $('#dg_detail').datagrid('getEditor', { index: index, field: 'unit' }); //下拉列表失去焦点事件 $("input", unitditor.target.next("span")).blur(function () { var flag = false; //判断该课程是否存在于下拉列表中datas获取的下拉列表中的数据 for (var i = 0 ; i < unit_list.length; i++) { if (unitditor.target.combobox('getValue') == unit_list[i].id && unitditor.target.combobox('getValue') != "") { flag = true; } } if (flag == false) { //赋值为空 unitditor.target.combobox('setValue', ''); } }); } });