【发布时间】:2017-02-01 17:28:36
【问题描述】:
我有一个 JQGrid,当打开行进行内联编辑时,我在列中显示一个下拉菜单。此下拉列表显示数据库中已经可用的列表项。当我从 clientArray 保存网格时,更新的数据保存在数据库中。
现在,我需要一个选项来在此下拉列表中添加一个新项目,并将该项目添加到数据库中,以便下次用户查看下拉列表时,新项目将可用。
请任何人帮忙找出是否有任何选项可以使用输入文本框制作下拉菜单,以便在运行时在下拉列表中添加新项目。
下面是我用来显示下拉菜单的示例代码。
mygrid = jQuery("#list").jqGrid({
url:url,
datatype: "json",
height: 'auto',
width: winW,
colNames:['id','cusipNo','Account No.','Account Type','Location Memo','Account Coding'],
colModel:[
{name:'Id',index:'stockRecordId',hidden:true,key: true,search: false},
{name:'cusipNo',index:'cusipNo',hidden:true},
{name:'accountNo',index:'accountNo',sortable:true,search: false, align: 'left',editable: true, width: 90, editrules:{custom: true, custom_func: validateAccountNo }},
{name:'accountType',index:'accountType',sortable:true,search: false, align: 'center',editable: true, width: 100},
{name:'locationMemo',index:'locationMemo',sortable:true,search: false, align: 'center',editable: true, width: 110},
{name:'accountCoding',index:'accountCoding',sortable:true,search: false, align: 'left',editable: true, width: 370, edittype: 'select',
editoptions: { dataUrl: accCodingUrl ,
buildSelect: function (data) {
var sel = '<select>';
$.each(JSON.parse(data),function(i,accountCoding){
sel += '<option value="'+accountCoding.key+'">'+accountCoding.value+'</option>';
});
return sel + "</select>";
}
}
}],
cmTemplate: {editable: true},
multiselect: false,
paging: true,
loadonce:true,
sortname: 'Id',
rowList: [],
rowNum:-1,
pager: $("#page"),
viewrecords: false,
pgbuttons: false,
pgtext: null,
【问题讨论】:
标签: javascript jqgrid free-jqgrid jqgrid-formatter jqgrid-php