Jqgrid 我正在使用JQ网格进行表单编辑。第二个下拉框上的数据将根据第一个下拉框上的值动态填充
请帮助,我是一个新的开发人员,我正在使用表单编辑。表单中有两个使用JQ网格的下拉框。第二个下拉列表中的数据将根据第一个下拉框中的值动态填充。我一直在这里阅读相关主题,并尝试了这些代码,但它仍然不适合我。这是我的密码。MedicineName的值取决于用户选择的MedicineType的值。请帮忙,我的密码哪里出了问题?我遵循了其他人在这里发布的内容,但它仍然填充了所有药物名称列表,而没有考虑第一个下拉框的价值(非常感谢您的帮助。谢谢Jqgrid 我正在使用JQ网格进行表单编辑。第二个下拉框上的数据将根据第一个下拉框上的值动态填充,jqgrid,Jqgrid,请帮助,我是一个新的开发人员,我正在使用表单编辑。表单中有两个使用JQ网格的下拉框。第二个下拉列表中的数据将根据第一个下拉框中的值动态填充。我一直在这里阅读相关主题,并尝试了这些代码,但它仍然不适合我。这是我的密码。MedicineName的值取决于用户选择的MedicineType的值。请帮忙,我的密码哪里出了问题?我遵循了其他人在这里发布的内容,但它仍然填充了所有药物名称列表,而没有考虑第一个下拉框的价值(非常感谢您的帮助。谢谢 var MedicineType = { 'allergy'
var MedicineType = { 'allergy': 'For Allergy / Itchiness', 'asthma': 'For Asthmatic Attacks','colds': 'For Colds / Cough', 'eye': 'For Eye Redness / Irritation','fever': 'For Fever and Pain','hyperacid': 'For Hyperacidity / Abdominal Pain' };
var MedicineName = { '1':'Paracetamol (Tempra 250mg/mL) syrup','2':'Paracetamol (Biogesic 250mg/mL) Syrup','3':'Paracetamol (Biogesic 500mg) tab','4':'Mefenamic Acid 250mg tab','5':'Mefenamic Acid 500mg tab','6':'Neozep Non-drowsy 10mg/500mg tab','7':'Carbocistene 500mg cap','8':'Loratadine (Allerta) 5mg/5ml syrup','9':'Loratidine 10mg tab','10':'Eye mo Eye drops','11':'Isonep Eye drops','12':'Tums 500mg tab','13':'Buscopan 10mg tab','14':'Buscopan Plus 10mg/500mg tab','15':'Salbutamol Nebulization' };
var MedicineTypecode = {
fever: { '1': 'Paracetamol (Tempra 250mg/mL) syrup', '2': 'Paracetamol (Biogesic 250mg/mL) Syrup','3': 'Paracetamol (Biogesic 500mg) tab' ,'4': 'Mefenamic Acid 250mg tab','5': 'Mefenamic Acid 500mg tab'},
colds: { '6': 'Neozep Non-drowsy 10mg/500mg tab', '7': 'Carbocistene 500mg cap' },
allergy: { '8': 'Loratadine (Allerta) 5mg/5ml syrup', '9': 'Loratidine 10mg tab' },
eye: { '10': 'Eye mo Eye drops','11': 'Eye mo Eye drops' },
hyperacid: { '12': 'Tums 500mg tabs','13': 'Buscopan 10mg tab','14': 'Buscopan Plus 10mg/500mg tab' },
asthma: { '15': 'Salbutamol Nebulization' }};
var lastSel = -1;
var grid = jQuery("#ClinicAvailMed");
var resetMedValues = function () {
grid.setColProp('MedicineName', { editoptions: { value: MedicineTypecode } });
};
$("#ClinicAvailMed").jqGrid({
datatype: "local",
height: 100,
width: 700,
colNames: ['ClinicAvailmed','MEDICINE TYPE','MEDICINES'],
colModel: [
{ name: 'ClinicAvailmed', index: 'ClinicAvailmed', sorttype: "int", editable: true, editoptions: { readonly: true, size: 2} },
{ name: 'MedTypeCode', index:'MedTypeCode', width: "50%", editable: true, formatter: 'select', edittype: "select", editoptions: { value: MedicineType ,dataInit: function (elem) {
var v = $(elem).val();
grid.setColProp('MedicineName', { editoptions: { value: MedicineTypecode [v]} });},dataEvents: [ {type: 'select', fn: function(e) {resetMedValues();
var v = parseInt($(e.target).val(), 10);
var sc = MedicineTypecode [v];
var newOptions = '';
for (var medId in sc) {
if (sc.hasOwnProperty(medId)) {
newOptions += '<option role="option" value="' +
medId + '">' +
med[medId] + '</option>';
} }
if ($(e.target).is('.FormElement')) {
// form editing
var form = $(e.target).closest('form.FormGrid');
$("select#MedicineName.FormElement", form[0]).html(newOptions);
} else {
// inline editing
var row = $(e.target).closest('tr.jqgrow');
var rowId = row.attr('id');
$("select#" + rowId + "_MedicineName", row[0]).html(newOptions);
} } } ] }},
{ name: 'Medcode', index: 'Medcode', width: "50%", editable: true, edittype: "select", editoptions: { value: MedicineName} }, ],
onSelectRow: function (id) {
if (id && id !== lastSel) {
if (lastSel != -1) {
resetMedValues();
grid.restoreRow(lastSel);
}
lastSel = id;
} },
ondblClickRow: function (id, ri, ci) {
if (id && id !== lastSel) {
grid.restoreRow(lastSel);
lastSel = id;
}
resetMedValues();
grid.editRow(id, true, null, null, 'clientArray', null,
function (rowid, response) { // aftersavefunc
grid.setColProp('MedicineName', { editoptions: { value: MedicineTypecode } }); });
return; },
multiselect: false,
caption: " ",
editurl: "handlers/store.ashx?table=ClinicAvailMed",
ondblClickRow: function(id) { { $("#ClinicAvailMed").editGridRow(id, { modal: true, drag: true, addCaption: "Add Medicine", editCaption: "Edit Medicine", bSubmit: "OK", bCancel: "Close", closeAfterEdit: true }); } }
});
$("#ClinicAvailMed").jqGrid('hideCol', 'ClinicAvailmed');
$("#btnAddClinicAmed").click(function() { $("#ClinicAvailMed").editGridRow('new', { modal: true, drag: true, addCaption: "Add Medicine", editCaption: "Edit Medicine", bSubmit: "OK", bCancel: "Close", closeAfterEdit: true, addedrow: 'last' }); });
$("#btnEditClinicAmed").click(function() {
var _selectedRow = $("#ClinicAvailMed").getGridParam('selrow');
if (_selectedRow != null) { $("#ClinicAvailMed").editGridRow(_selectedRow, { modal: true, drag: true, addCaption: "Add Medicine", editCaption: "Edit Medicine", bSubmit: "OK", bCancel: "Close", closeAfterEdit: true }); }
else { alert("Please select the row which you want to edit."); }});
$("#btnDeleteClinicAmed").click(function() {
var _selectedRow = $("#ClinicAvailMed").getGridParam('selrow');
if (_selectedRow != null) { $("#ClinicAvailMed").delGridRow(_selectedRow, { drag: true, msg: "Delete the row(s)?", caption: "Delete", bSubmit: "Yes", bCancel: "Close", modal: true }); }
else { alert("Please select the row which you want to edit."); } });
var MedicineType={‘过敏’:‘过敏/瘙痒’、‘哮喘’:‘哮喘发作’、‘感冒’:‘感冒/咳嗽’、‘眼睛’:‘眼睛发红/发炎’、‘发烧’:‘发烧和疼痛’、‘胃酸过多’:‘胃酸过多/腹痛’;
var MedicineName={'1':'Paracetamol(Tempra 250mg/mL)糖浆','2':'Paracetamol(Biogesic 250mg/mL)糖浆','3':'Paracetamol(Biogesic 500mg)标签','4':'Mefenamic Acid 250mg标签','5':'Mefenamic Acid 500mg标签','6':'Neozep非嗜睡10mg/500mg标签','7':'carboncistene 500mg帽子','8':'Loratadine(Allerta)5mg/5ml糖浆','9':'氯雷他定10mg标签','10':'mo滴眼液','11':'Isonep滴眼液','12':'Tums 500mg标签','13':'Buscopan 10mg标签','14':'Buscopan+10mg/500mg标签','15':'Salbutamol雾化';
var MedicineTypecode={
发烧:{'1':'Paracetamol(Tempra 250mg/mL)糖浆','2':'Paracetamol(Biogesic 250mg/mL)糖浆','3':'Paracetamol(Biogesic 500mg)标签','4':'Mefenamic Acid 250mg标签','5':'Mefenamic Acid 500mg标签',
感冒:{'6':'Neozep不嗜睡10mg/500mg标签','7':'Carbocistene 500mg帽',
过敏:{'8':'氯雷他定(Allerta)5mg/5ml糖浆','9':'氯雷他定10mg标签',
眼睛:{'10':'滴眼液','11':'滴眼液',
超强酸:{'12':'Tums 500mg标签','13':'Buscopan 10mg标签','14':'Buscopan Plus 10mg/500mg标签',
哮喘:{'15':'沙丁胺醇雾化吸入'};
var lastSel=-1;
var grid=jQuery(“有效”);
var resetMedValues=函数(){
setColProp('MedicineName',{editoptions:{value:MedicineTypecode}});
};
$(“#可用”).jqGrid({
数据类型:“本地”,
身高:100,
宽度:700,
colname:['clinicavailed'、'MEDICINE TYPE'、'MEDICINES'],
colModel:[
{name:'ClinicAvailmed',index:'ClinicAvailmed',sorttype:'int',editable:true,editoptions:{readonly:true,size:2}},
{名称:'MedTypeCode',索引:'MedTypeCode',宽度:“50%”,可编辑:true,格式化程序:'select',编辑类型:'select',编辑选项:{value:MedicineType,dataInit:function(elem){
var v=$(elem.val();
setColProp('MedicineName',{editoptions:{value:MedicineTypecode[v]}}};},dataEvents:[{type:'select',fn:function(e){resetMedValues();
var v=parseInt($(e.target).val(),10);
var sc=药物类型代码[v];
var newOptions='';
用于(sc中的var medId){
if(sc.hasOwnProperty(medId)){
新选项+=“”+
医学[医学]+'';
} }
if($(e.target).is('.FormElement')){
//表单编辑
var form=$(e.target.closest('form.FormGrid');
$(“选择#MedicineName.FormElement”,表单[0]).html(新选项);
}否则{
//内联编辑
var行=$(e.target).closest('tr.jqgrow');
var rowId=row.attr('id');
$(“选择#”+rowId+“_MedicineName”,第[0]行。).html(新选项);
} } } ] }},
{name:'Medcode',index:'Medcode',width:'50%',可编辑:true,edittype:'select',editoptions:{value:MedicineName}},],,
OnSetrow:功能(id){
if(id&&id!==lastSel){
如果(lastSel!=-1){
resetMedValues();
grid.restoreRow(lastSel);
}
lastSel=id;
} },
ondblClickRow:函数(id、ri、ci){
if(id&&id!==lastSel){
grid.restoreRow(lastSel);
lastSel=id;
}
resetMedValues();
editRow(id,true,null,null,'clientArray',null,
函数(rowid,response){//aftersavefunc
setColProp('MedicineName',{editoptions:{value:MedicineTypecode}});});
返回;},
多选:错,
标题:“,
editurl:“handlers/store.ashx?table=clinicavailed”,
ondblClickRow:function(id){$(“#ClinicAvailMed”).editGridRow(id,{modal:true,drag:true,addCaption:“添加药物”,editCaption:“编辑药物”,bSubmit:“确定”,bCancel:“关闭”,closeAfterEdit:true}}
});
$(“#ClinicAvailMed”).jqGrid('hideCol','ClinicAvailMed');
$(“#btnAddClinicAmed”)。单击(函数(){($(“#ClinicAvailMed”).editGridRow('new',{modal:true,drag:true,addCaption:'Add Medicine',editCaption:'Edit Medicine',bSubmit:'OK',bCancel:'Close',closeAfterEdit:true,adddrow:'last'});
$(“#btnEditClinicAmed”)。单击(函数(){
var _selectedRow=$(“#ClinicAvailMed”).getGridParam('selrow');
如果(_selectedRow!=null){$(“#ClinicAvailMed”).editGridRow(_selectedRow,{modal:true,drag:true,addCaption:“添加药物”,editCaption:“编辑药物”,bSubmit:“确定”,bCanc