gpt4 book ai didi

javascript - fetchItemByIdentity() 没有按预期工作

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:06:46 25 4
gpt4 key购买 nike

我的页面上有一个 ItemFileWriteStore。当我单击 DataGrid 中的任何行时,我可以获得该行的 ID,但是当我尝试使用该 ID 执行 fetchItemByIdentity 时,它总是返回 null 。知道为什么会这样吗?

我正在使用 Dojo 1.5。

function getRemoveFormatter(id) {
return '<a href="#" onclick="deleteItem(' + id + ');return false;"><img src="/images/icons/delete.png" /></a>';
}

function deleteItem(id) {
console.log(id);
window.grid.store.fetchItemByIdentity({
identity: id,
onItem: function(item, request) { console.log(item); }
});
//window.grid.store.deleteItem(id);
}

dojo.ready(function() {
var store = new dojo.data.ItemFileWriteStore({data:{items:[]}});
window.grid = new dojox.grid.DataGrid({
store: store,
structure: [
{ name: "id", field: "id", width: "50px" },
{ name: "Stylist", field: "stylist", width: "100px" },
{ name: "Service", field: "service", width: "200px" },
{ name: "Length", field: "length", width: "50px" },
{ name: "Remove", field: "remove", width: "30px", formatter: getRemoveFormatter }
],
identifier: "id",
label: "id"});
dojo.byId("services_grid").appendChild(grid.domNode);
grid.startup();
observeAppointmentServiceAddClick(window.grid);
getAppointmentItems();
});

最佳答案

尝试对您声明商店和网格的方式做一点小改动。标识符和标签属性属于商店的商品旁边的数据部分。

var store = new dojo.data.ItemFileWriteStore({data:{
items:[],
identifier: "id",
label: "id"}});

window.grid = new dojox.grid.DataGrid({
store: store,
structure: [
{ name: "id", field: "id", width: "50px" },
{ name: "Stylist", field: "stylist", width: "100px" },
{ name: "Service", field: "service", width: "200px" },
{ name: "Length", field: "length", width: "50px" },
{ name: "Remove", field: "remove", width: "30px", formatter: getRemoveFormatter }
]});

关于javascript - fetchItemByIdentity() 没有按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5811931/

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