C# 如何在一个网格中的同一列中创建两个图像?

C# 如何在一个网格中的同一列中创建两个图像?,c#,asp.net-mvc-4,slickgrid,C#,Asp.net Mvc 4,Slickgrid,我正在尝试在我的slickgrid的一列中选择并删除图像,但无法执行此操作。我知道如何做这样一个单一的图像按钮: var column = {id:delCol, field:'del', name:'Delete', width:250, formatter:buttonFormatter} //Now define your buttonFormatter function function buttonFormatter(row,cell,value,columnDef,dataCont

我正在尝试在我的slickgrid的一列中选择并删除图像,但无法执行此操作。我知道如何做这样一个单一的图像按钮:

var column = {id:delCol, field:'del', name:'Delete', width:250, formatter:buttonFormatter}

//Now define your buttonFormatter function
function buttonFormatter(row,cell,value,columnDef,dataContext){  
    var button = "<input class='del' type='button' id='"+ dataContext.id +"' />";
    //the id is so that you can identify the row when the particular button is clicked
    return button;
    //Now the row will display your button
}
var column={id:delCol,字段:'del',名称:'Delete',宽度:250,格式化程序:buttonFormatter}
//现在定义buttonFormatter函数
函数按钮信息格式(行、单元格、值、列定义、数据上下文){
var按钮=”;
//id为,以便在单击特定按钮时可以识别行
返回按钮;
//现在,该行将显示您的按钮
}

关于如何做到这一点,您有什么想法吗?

该单元格的数据应包括图像/按钮作为数组或{}(对象)所需的任何内容

然后创建一个格式化程序,以便在单元格中同时使用这两种格式:

// if value is [dataContext.delete.id, dataContext.add.id] for example
function twoButtonFormatter(row, cell, value, columnDef, dataContext) {
  var str = ''; // initialize a string

  // First button
  str += "<input class='del' type='button' id='"+ value[0] +"' /> ";

  // second button
  str += "<button data-id='"+value[1]+"' class='add'>Add</button>";

  // return the html string of both buttons
  return str;
}
//例如,如果值为[dataContext.delete.id,dataContext.add.id]
函数TwoButtonInformation(行、单元格、值、列定义、数据上下文){
var str='';//初始化字符串
//第一个按钮
str+=”;
//第二个按钮
str+=“添加”;
//返回两个按钮的html字符串
返回str;
}

效果很好,奇怪的是,我以前尝试过类似的方法,但却出现了错误。一定是有什么设置不正确。谢谢你的代码片段。