Infragistics 使用字符串主键删除行
Infragistics delete row using string primaryKey
我有一个 Infragistics 网格,当网格的主键是数据类型字符串时,我无法删除一行。
我无法将我的主键设置为数据类型数字,因为它的格式为:"KIT_001"。有没有什么巧妙的方法可以使用删除按钮并能够删除具有此类数据的行?也许有一种方法可以设置递增的 ID 并将其用于删除按钮?
var dataSource = [
{"ProductID": "KIT_001", "Name": "Kit 1", "ProductNumber": "P4857"},
{"ProductID": "KIT_002", "Name": "Kit 2", "ProductNumber": "P4567"},
{"ProductID": "KIT_003", "Name": "Kit 3", "ProductNumber": "P4447"}
]
$(function () {
$("#grid").igGrid({
autoGenerateColumns: false,
width: "100%",
height: "500px",
columns: [
{ headerText: "Product ID", key: "ProductID", dataType: "string", width: "10%" },
{ headerText: "Product Name", key: "Name", dataType: "string", width: "30%" },
{ headerText: "Product Number", key: "ProductNumber", dataType: "string", width: "25%" },
{ headerText: "", key: "Delete", dataType: "string", width: "10%", unbound: true,
template: "<input type='button' onclick='deleteRow(${ProductID})' value='Delete' class='delete-button'/>"},
],
primaryKey: "ProductID",
dataSource: dataSource,
features: [
{
name: "Updating",
enableAddRow: false,
editMode: "row",
enableDeleteRow: false,
}
]
});
});
function deleteRow(rowId) { console.log('rowId ',rowId)
var grid = $("#grid").data("igGrid");
grid.dataSource.deleteRow(rowId);
grid.commit();
}
在模板中用引号括起关键参数:
template: "<input type='button' onclick='deleteRow(\"${ProductID}\")' value='Delete' class='delete-button'/>"
我有一个 Infragistics 网格,当网格的主键是数据类型字符串时,我无法删除一行。
我无法将我的主键设置为数据类型数字,因为它的格式为:"KIT_001"。有没有什么巧妙的方法可以使用删除按钮并能够删除具有此类数据的行?也许有一种方法可以设置递增的 ID 并将其用于删除按钮?
var dataSource = [
{"ProductID": "KIT_001", "Name": "Kit 1", "ProductNumber": "P4857"},
{"ProductID": "KIT_002", "Name": "Kit 2", "ProductNumber": "P4567"},
{"ProductID": "KIT_003", "Name": "Kit 3", "ProductNumber": "P4447"}
]
$(function () {
$("#grid").igGrid({
autoGenerateColumns: false,
width: "100%",
height: "500px",
columns: [
{ headerText: "Product ID", key: "ProductID", dataType: "string", width: "10%" },
{ headerText: "Product Name", key: "Name", dataType: "string", width: "30%" },
{ headerText: "Product Number", key: "ProductNumber", dataType: "string", width: "25%" },
{ headerText: "", key: "Delete", dataType: "string", width: "10%", unbound: true,
template: "<input type='button' onclick='deleteRow(${ProductID})' value='Delete' class='delete-button'/>"},
],
primaryKey: "ProductID",
dataSource: dataSource,
features: [
{
name: "Updating",
enableAddRow: false,
editMode: "row",
enableDeleteRow: false,
}
]
});
});
function deleteRow(rowId) { console.log('rowId ',rowId)
var grid = $("#grid").data("igGrid");
grid.dataSource.deleteRow(rowId);
grid.commit();
}
在模板中用引号括起关键参数:
template: "<input type='button' onclick='deleteRow(\"${ProductID}\")' value='Delete' class='delete-button'/>"