如何在jqgrid中在同一列中显示多个值

如何在jqgrid中在同一列中显示多个值,jqgrid,Jqgrid,我想知道如何在jqGrid的一列中显示多个值 下面是我当前网格定义的一个示例 $("#grid1").jqGrid({ url: 'Default.aspx/getGridData', datatype: 'json', ... colModel: [ ... //contains the input type ('select', etc.) { name: 'InputType', hidden:true }, ... //may contain a string of select op

我想知道如何在jqGrid的一列中显示多个值

下面是我当前网格定义的一个示例

$("#grid1").jqGrid({
url: 'Default.aspx/getGridData',
datatype: 'json',
...
colModel: [
...
//contains the input type ('select', etc.)
{ name: 'InputType', hidden:true }, 
...
//may contain a string of select options ('<option>Option1</option>'...)
{ 
  name: 'Input', 
  editable:true, 
  edittype:'custom', 
  editoptions:{
     custom_element: /* want cell value from InputType column here */ , 
     custom_value:   /* want cell value from Input column here */ 
  } 
 }, 
...
]
});

通过在柱模型上使用a,可以很容易地做到这一点

自定义格式化程序是具有以下参数的javascript函数:

cellvalue—要格式化的值

选项-{rowId:rid,colModel:cm},其中rowId-是 row colModel是此列的属性的对象 来自jqGrid的colModel数组

rowObject—是一个行数据,其表示格式由 数据类型选项

因此,函数可以这样声明:

function myformatter ( cellvalue, options, rowObject )
{
     // format the cellvalue to new format
     return new_formated_cellvalue;
}
并在您的列上定义如下:

   {name:'price', index:'price', width:60, align:"center", editable: true, 
 formatter:myformatter },
因此,在您的情况下,可以使用自定义格式化程序中的rowObject参数来填充其他值。 比如说

柱模型

格式化程序

如果在employee_id列中定义了此项,则它将显示在单元格中:

employee_id email username

这里有一个例子说明它的工作原理。

两个值是什么意思?您可以简单地在一个变量中组合两个值,然后在gridComplete中使用setCol更改该值。请清楚地解释你的要求。colNames:['id','rev','employee\u id','email','user\u name','active','is\u志愿者','is\u first\u time\u user']我有这些栏,但我只想要三栏。一个是'id','rev',第三列应该包含所有剩余的列值。。。你能建议我如何用完整的代码来做吗。我是jquery新手。看看这段代码,实际上你要说的是绝对正确的。。我将展示我的示例代码,以便您能够清楚地了解我的问题所在。{名称:'user_name',索引:'user_name',宽度:400,标签:'user_name',格式设置器:函数cellvalue,选项,行对象{addPart1=rowObject.user\u name;addPart2=rowObject.active;addPart3=rowObject.is\u志愿者;addPart4=rowObject.is\u首次\u用户;fullAddress=addPart1+addPart2+addPart3+addPart4;返回fullAddress;}这就是我用来合并的东西,但我不明白。你如何扩展你的示例小提琴,使它在整理表格后也能工作?@Preexo问了一个很好的澄清问题。我也希望得到一个答案。
function myformatter ( cellvalue, options, rowObject )
{
     return cellvalue + ' ' + rowObject.email + ' ' + rowObject.user_name;
}
employee_id email username