我在 colModel 中定义时遇到 jqgrid 问题edittype: 'select', formatter: 'select' 这是我的 colModel:
colModel:
[
{ name: 'sdv_idreclamo', index: 'sdv_idreclamo', editable: true, edittype: 'text', editoptions: { defaultValue: Idreclamo }, hidden: true },
{ name: 'sdv_parpieza', index: 'sdv_parpieza', align: 'left', width: '35', editable: true, edittype: 'select', editoptions: { dataUrl: '@Url.Action("CargaDropDown", "raTabDatosVehiculo", new { param = "PIEZA"})', buildSelect: createSelectList} },
{ name: 'sdv_parcodclase', index: 'sdv_parcodclase', sortable: true, align: 'left', width: '35', editable: true, edittype: 'select', editoptions: { dataUrl: '@Url.Action("CargaDropDown", "raTabDatosVehiculo", new { param = "CODCLASE"})', buildSelect: createSelectList} }
....
],
当我查看网页时,不显示描述只显示值。例如,列 sdv_pieza 描述为“AMORTIGUADOR”值:001,当它加载网格显示 001 时。我希望它显示“AMORTIGUADOR”我在 sdv_pieza 添加了格式化程序:'select':
{ name: 'sdv_parpieza', index: 'sdv_parpieza', align: 'left', width: '35', editable: true, edittype: 'select', formatter: 'select', editoptions: { dataUrl: '@Url.Action("CargaDropDown", "raTabDatosVehiculo", new { param = "PIEZA"})', buildSelect: createSelectList} },
当它加载网格时,列 sdv_pieza 是无效的!我在此列中不显示任何内容吗
dataUrl 返回良好的参数并使用 buildSelect 构建选择:createSelectList
createSelectList = function (data) {
var response, s = '<select>', i;
response = jQuery.parseJSON(data);
if (response && response.length) {
$.each(response, function (i) {
s += '<option value="' + this.cp_idparametro + '">' + this.cp_descparametro + '</option>';
});
}
return s + '</select>';
}
这是我将数据检索到 jqgrid 并进行编辑时的图像: