如何在jqGrid列中显示不同的值

时间:2010-03-01 22:13:03

标签: jquery jqgrid

我有一个带有可编辑列some_other_id的jGrid,其中包含一个选项下拉列表,其键/值为1:A,2:B,3:C。我希望每行中的所选选项显示所选内容的文本值(例如“A”,“B”,“C”),而不是ID(1,2或3)。它目前显示ID。

colModel :[
    { label: 'ID', name:'id' },
    { 
        label: 'Some Other ID',
        name: 'some_other_id',
        editable: true,
        align: 'center',
        edittype: "select",
        editoptions: {value:"1:A,2:B,3:C"}
    },
],

如何让它显示editoptions的所选文字值?

2 个答案:

答案 0 :(得分:3)

只需在列模型中使用formatter:'select'

参考:trirand_jqgridwiki_wiki:predefined_formatter

答案 1 :(得分:0)

这似乎不重要,但jqGrid documentation使用以下语法:

value: {1:'A',2:'B'}

或者,我在我的应用程序中使用了以下语法:

value: "5:'A';4:'B'"

尝试一下,看看这是否会对您的应用程序产生影响。