带有键值的jqgrid typeahead
jqgrid typeahead with key value
我正在使用 twitter bootstrap typeahead 和 Guriddo jqgrid Version 5.2.1 表单编辑。我更愿意用键值对而不是值来做到这一点。下面的所有代码都可以正常工作,唯一缺少的是当为现有记录打开编辑表单时,它显示键(数字)而不是值(公司名称)。网格列都是动态创建的。我认为如果在 editoptions 中,如果我可以指定一个值:公司名称,这可能是一个很好的解决方法,但这不起作用。
label: svf.fieldLabel,
name: svf.tf[0].nativename,
width: 150,
editable: true,
edittype: "text",
formatter: 'select',
formatoptions:
{
value: getEditOptionsValue(svf.relatedItemId)
},
editoptions: {
dataInit: function (element) {
var data = JSON.parse(getSelects(svf.relatedItemId));
$(element).attr("autocomplete", "off").typeahead({
appendTo: "body",
dataType: "json",
displayText: function (item) { return item.name; },
source: function (query, process) {
return process(data);
}
});
} //end datainit
}//end edit options
为了解决您的问题,您需要使用自定义格式取消功能。
预定义的取消格式化函数 return 键而不是值。
您可以在我们的 documentation here
中看到更多内容
您可以使用以下代码:
label: svf.fieldLabel,
name: svf.tf[0].nativename,
width: 150,
editable: true,
edittype: "text",
formatter: 'select',
unformat : function(value, options, cellObject) {
return value;
},
我正在使用 twitter bootstrap typeahead 和 Guriddo jqgrid Version 5.2.1 表单编辑。我更愿意用键值对而不是值来做到这一点。下面的所有代码都可以正常工作,唯一缺少的是当为现有记录打开编辑表单时,它显示键(数字)而不是值(公司名称)。网格列都是动态创建的。我认为如果在 editoptions 中,如果我可以指定一个值:公司名称,这可能是一个很好的解决方法,但这不起作用。
label: svf.fieldLabel,
name: svf.tf[0].nativename,
width: 150,
editable: true,
edittype: "text",
formatter: 'select',
formatoptions:
{
value: getEditOptionsValue(svf.relatedItemId)
},
editoptions: {
dataInit: function (element) {
var data = JSON.parse(getSelects(svf.relatedItemId));
$(element).attr("autocomplete", "off").typeahead({
appendTo: "body",
dataType: "json",
displayText: function (item) { return item.name; },
source: function (query, process) {
return process(data);
}
});
} //end datainit
}//end edit options
为了解决您的问题,您需要使用自定义格式取消功能。 预定义的取消格式化函数 return 键而不是值。 您可以在我们的 documentation here
中看到更多内容您可以使用以下代码:
label: svf.fieldLabel,
name: svf.tf[0].nativename,
width: 150,
editable: true,
edittype: "text",
formatter: 'select',
unformat : function(value, options, cellObject) {
return value;
},