0

我试图在我的 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
}

关于如何做到这一点的任何想法?

4

1 回答 1

1

该单元格的数据应包括图像/按钮所需的任何内容,无论是数组还是 {}(对象)。

然后在一个单元格中创建一个格式化程序:

// 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;
}
于 2013-04-30T23:05:25.603 回答