我试图在我的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
}
关于如何做到这一点的任何想法?
答案 0 :(得分: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;
}