//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: '編號', width: 40, align: 'center' }, { field: 'goods_class', title: '物品分類', width: 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: '物品簡稱', width: 100, align: 'center', editor: { type: 'textbox', options: { required: true, editable: true } } }, { field: 'goods_full_name', title: '物品名稱/規格描述', width: 180, align: 'center', editor: { type: 'textbox', options: { required: true, editable: true } } }, { field: 'product_line', title: 'Product Line', width: 100, align: 'center', editor: { type: 'combobox', options: { valueField: 'dictionary_name', textField: 'dictionary_name', url: '', required: true, editable: false } } }, { field: 'qty', title: '請購數量', width: 80, align: 'center', editor: { type: 'numberbox', options: { min: 0.01, precision: 2, required: true, editable: true } } }, { field: 'unit', title: '單位', width: 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', ''); } }); } });