gpt4 book ai didi

jquery - 使用 jQuery 中的复合主键更新 infragistics igGrid

转载 作者:行者123 更新时间:2023-12-01 01:13:34 27 4
gpt4 key购买 nike

我正在使用 Infragistics igGrid,其中我有多个主键:

 $("#grid_selector").igGrid({
autoCommit: true,
width: "100%",
height: '500px',
autoGenerateColumns: false,
primaryKey: "TrackTrainId,ClassCode",
columns: [
{ headerText: "Class Code", key: "ClassCode", dataType: "string" },
{ headerText: "Track/Train", key: "TrackTrainId", dataType: "string" },
{ headerText: "Cars", key: "NumberOfCars", dataType: "number" },
{ headerText: "Loads", key: "LoadEquipments", dataType: "string" },
{ headerText: "Empties", key: "EmptyEquipments", dataType: "string" },
{ headerText: "Tons", key: "Tons", dataType: "number" },
{ headerText: "Feet", key: "Feet", dataType: "number" },
],
features: [
{
name: "Updating",
editMode: "none",
enableAddRow: false,
enableDeleteRow: false
}
]
});

网格最初不会有任何数据。当用户单击“添加行”按钮时,它将调用另一个函数在网格中添加新行。以下是添加行的代码,运行良好:

//add rows to the grid to show selected equipments first time
AddRowForEquipmentSelectedGrid = function (track_info, ul_eq) {
var selctd = $('#' + ul_eq + ' li.ui-selected'),
grid = $("#grid_selector");

var rowObj = {
"TrackTrainId": track_info.TrackTrainId,
"ClassCode": track_info.ClassCode,
"NumberOfCars": track_info.NumberOfCars,
"LoadEquipments": track_info.LoadEquipments,
"EmptyEquipments": track_info.EmptyEquipments,
"Tons": track_info.Tons,
"Feet": track_info.Feet
};

grid.igGridUpdating("addRow", rowObj);
};

当我尝试更新网格行时出现问题。如何传递主键。如果我有任何一个主键,那么这段代码就可以正常工作。我将多个键传递为 { "TrackTrainId": track_id, "ClassCode": class_code }

//on update equipment
UpdateEquipmentGrid = function (track_id, class_code, total_cars, txt_load, txt_emp, txt_tons, txt_feet) {
var rowObj = {
"NumberOfCars": total_cars,
"LoadEquipments": txt_load,
"EmptyEquipments": txt_emp,
"Tons": txt_tons,
"Feet": txt_feet
};
$('#grid_selector').igGridUpdating("updateRow", { "TrackTrainId": track_id, "ClassCode": class_code }, rowObj);
}

不知道这是否是正确的方法。任何建议我在这里做错了什么。

最佳答案

目前 igGrid 不支持复合主键。您可以将不同列中的值组合到一个字段中并将其用作主键。例如:

 rowObj.CompositeKey = rowObj.ClassCode + "|" + rowObj.TrackTrainId;

您可以根据该复合值更新相关行:

 $("#grid").igGridUpdating("updateRow", "another random string|some random string", { NumberOfCars: 1000 });

您可以在这里引用以下 JSFiddle 示例: http://jsfiddle.net/2uf32hm3/2/

关于jquery - 使用 jQuery 中的复合主键更新 infragistics igGrid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41194564/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com