JqGrid 根据另一个 jqgrid 下拉列表中的选定数据在下拉列表中添加值
JqGrid add value on dropdown base on selected data on another jqgrid dropdown
您好,我目前无法了解 jqgrid 的情况。例如,如果我 select sports 另一个下拉列表将有一个 list of sports 的数据。
我可以加载数据,但我不知道如何开始。
这是我的代码
$('#d1d2-lot-information-grid').jqGrid('clearGridData').trigger("reloadGrid");
$('#d1d2-lot-information-grid').jqGrid({
datatype: 'local',
data: lots,
editurl: 'clientArray',
colNames: ['Device', 'Package', 'Lot No.', 'Lot Qty'],
colModel: [
{ name: 'Device', index: 'Device', sortable: false, editable: true, editrules: { required: true }, edittype: 'select', },
{
name: 'Package',
index: 'Package',
sortable: false,
editable: true,
editrules: { required: true },
edittype: 'select',
editoptions: { value: packageOptions },
},
{ name: 'LotNo', index: 'LotNo', sortable: false, editable: true, editrules: { required: true }, },
{ name: 'LotQty', index: 'LotQty', sortable: false, editable: true, editrules: { required: true }, }
],
beforeSelectRow: function (id) {
if ($('#' + id).attr('editable') == 1) {
return false;
}
},
pager: '#d1d2-lot-information-pager',
pgbuttons: false,
pginput: false,
sortorder: 'asc',
sortname: 'name',
multiselect: true,
height: '130',
maxheight: '130',
width: '522',
viewrecords: true,
rowNum: 10000
});
$('#d1d2-lot-information-grid').jqGrid({ recreateForm: true })
// Disable form CRUD
$('#d1d2-lot-information-grid').jqGrid('navGrid', '#d1d2-lot-information-pager', { edit: false, save: false, add: false, cancel: false, del: show, search: false, refresh: false });
// Enable inline CRUD
$('#d1d2-lot-information-grid').jqGrid('inlineNav', '#d1d2-lot-information-pager', { add: show, edit: show, save: show, cancel: show });
}
我对 jqgrid 有点陌生
抱歉我的英语不好希望你能理解我
它应该适用于内联添加和内联编辑
如果你使用Guriddo jqGrid you can use our example in our knowledge base here
用这段代码解决我的问题。
有点乱,但可以满足我的需要
$('#d1d2-lot-information-grid').jqGrid({
datatype: 'local',
data: lots,
editurl: 'clientArray',
colNames: ['Device', 'Package', 'Lot No.', 'Lot Qty'],
colModel: [
{ name: 'Device', index: 'Device', sortable: false, editable: true, editrules: { required: true }, edittype: 'select', editoptions:{value:':-Select Device-'} },
{
name: 'Package',
index: 'Package',
sortable: false,
editable: true,
editrules: { required: true },
edittype: 'select',
editoptions: { value: packageOptions,dataEvents: [
{
type: 'change',
fn: function(e) {
var packageID = $(this).val();
var selr = jQuery('#d1d2-lot-information-grid').jqGrid('getGridParam', 'selrow');
var modes = [],
params = { packageID:packageID };
$.ajax({
async: false,
type: 'POST',
contentType: 'application/json',
url: baseUrl + 'ncrb/Default.aspx/GetDevice',
data: JSON.stringify(params),
dataType: 'json',
success: function (data) { modes = data; },
error: function (xhr, status, error) { console.log(xhr, status, error); }
});
var targetrow = '#'+selr + '_Device';
$(targetrow).empty();
var items="";
$.each(modes, function (key, value) {
items = '<option value="' + value.Description + '">' + value.Description + '</option>';
$(targetrow).append(items);
});
return modes;
}
}
] },
},
{ name: 'LotNo', index: 'LotNo', sortable: false, editable: true, editrules: { required: true }, },
{ name: 'LotQty', index: 'LotQty', sortable: false, editable: true, editrules: { required: true }, }
],
beforeSelectRow: function (id) {
if ($('#' + id).attr('editable') == 1) {
return false;
}
},
pager: '#d1d2-lot-information-pager',
pgbuttons: false,
pginput: false,
sortorder: 'asc',
sortname: 'name',
multiselect: true,
height: '130',
maxheight: '130',
width: '522',
viewrecords: true,
rowNum: 10000
});
$('#d1d2-lot-information-grid').jqGrid({ recreateForm: true })
// Disable form CRUD
$('#d1d2-lot-information-grid').jqGrid('navGrid', '#d1d2-lot-information-pager', { edit: false, save: false, add: false, cancel: false, del: show, search: false, refresh: false });
// Enable inline CRUD
$('#d1d2-lot-information-grid').jqGrid('inlineNav', '#d1d2-lot-information-pager', { add: show, edit: show, save: show, cancel: show });
您好,我目前无法了解 jqgrid 的情况。例如,如果我 select sports 另一个下拉列表将有一个 list of sports 的数据。 我可以加载数据,但我不知道如何开始。
这是我的代码
$('#d1d2-lot-information-grid').jqGrid('clearGridData').trigger("reloadGrid");
$('#d1d2-lot-information-grid').jqGrid({
datatype: 'local',
data: lots,
editurl: 'clientArray',
colNames: ['Device', 'Package', 'Lot No.', 'Lot Qty'],
colModel: [
{ name: 'Device', index: 'Device', sortable: false, editable: true, editrules: { required: true }, edittype: 'select', },
{
name: 'Package',
index: 'Package',
sortable: false,
editable: true,
editrules: { required: true },
edittype: 'select',
editoptions: { value: packageOptions },
},
{ name: 'LotNo', index: 'LotNo', sortable: false, editable: true, editrules: { required: true }, },
{ name: 'LotQty', index: 'LotQty', sortable: false, editable: true, editrules: { required: true }, }
],
beforeSelectRow: function (id) {
if ($('#' + id).attr('editable') == 1) {
return false;
}
},
pager: '#d1d2-lot-information-pager',
pgbuttons: false,
pginput: false,
sortorder: 'asc',
sortname: 'name',
multiselect: true,
height: '130',
maxheight: '130',
width: '522',
viewrecords: true,
rowNum: 10000
});
$('#d1d2-lot-information-grid').jqGrid({ recreateForm: true })
// Disable form CRUD
$('#d1d2-lot-information-grid').jqGrid('navGrid', '#d1d2-lot-information-pager', { edit: false, save: false, add: false, cancel: false, del: show, search: false, refresh: false });
// Enable inline CRUD
$('#d1d2-lot-information-grid').jqGrid('inlineNav', '#d1d2-lot-information-pager', { add: show, edit: show, save: show, cancel: show });
}
我对 jqgrid 有点陌生 抱歉我的英语不好希望你能理解我 它应该适用于内联添加和内联编辑
如果你使用Guriddo jqGrid you can use our example in our knowledge base here
用这段代码解决我的问题。 有点乱,但可以满足我的需要
$('#d1d2-lot-information-grid').jqGrid({
datatype: 'local',
data: lots,
editurl: 'clientArray',
colNames: ['Device', 'Package', 'Lot No.', 'Lot Qty'],
colModel: [
{ name: 'Device', index: 'Device', sortable: false, editable: true, editrules: { required: true }, edittype: 'select', editoptions:{value:':-Select Device-'} },
{
name: 'Package',
index: 'Package',
sortable: false,
editable: true,
editrules: { required: true },
edittype: 'select',
editoptions: { value: packageOptions,dataEvents: [
{
type: 'change',
fn: function(e) {
var packageID = $(this).val();
var selr = jQuery('#d1d2-lot-information-grid').jqGrid('getGridParam', 'selrow');
var modes = [],
params = { packageID:packageID };
$.ajax({
async: false,
type: 'POST',
contentType: 'application/json',
url: baseUrl + 'ncrb/Default.aspx/GetDevice',
data: JSON.stringify(params),
dataType: 'json',
success: function (data) { modes = data; },
error: function (xhr, status, error) { console.log(xhr, status, error); }
});
var targetrow = '#'+selr + '_Device';
$(targetrow).empty();
var items="";
$.each(modes, function (key, value) {
items = '<option value="' + value.Description + '">' + value.Description + '</option>';
$(targetrow).append(items);
});
return modes;
}
}
] },
},
{ name: 'LotNo', index: 'LotNo', sortable: false, editable: true, editrules: { required: true }, },
{ name: 'LotQty', index: 'LotQty', sortable: false, editable: true, editrules: { required: true }, }
],
beforeSelectRow: function (id) {
if ($('#' + id).attr('editable') == 1) {
return false;
}
},
pager: '#d1d2-lot-information-pager',
pgbuttons: false,
pginput: false,
sortorder: 'asc',
sortname: 'name',
multiselect: true,
height: '130',
maxheight: '130',
width: '522',
viewrecords: true,
rowNum: 10000
});
$('#d1d2-lot-information-grid').jqGrid({ recreateForm: true })
// Disable form CRUD
$('#d1d2-lot-information-grid').jqGrid('navGrid', '#d1d2-lot-information-pager', { edit: false, save: false, add: false, cancel: false, del: show, search: false, refresh: false });
// Enable inline CRUD
$('#d1d2-lot-information-grid').jqGrid('inlineNav', '#d1d2-lot-information-pager', { add: show, edit: show, save: show, cancel: show });