The dojox.grid package is an older version of the Dojo Toolkit's grid component. It is not actively maintained and is superseded by the newer dgrid package. However, in the dojox.grid package, adding a new row dynamically can be done using the store.newItem() method instead of store.put({}). Here's an example of how you can dynamically add a row to a dojox.grid.DataGrid:

// Assuming you have a data store and a grid set up
var store = new dojox.data.JsonRestStore({ target: "/your/data/url" });
var grid = new dojox.grid.DataGrid({ store: store }, "gridNode");

// Create a new item and add it to the store
var newItem = store.newItem();
store.setValue(newItem, "id", 1);
store.setValue(newItem, "name", "John Doe");
store.setValue(newItem, "age", 30);

// Commit the changes to the store
store.save();

// Refresh the grid to show the new row
grid.update();

Note that after adding the new item to the store, you need to call store.save() to commit the changes to the server. Then, you can call grid.update() to refresh the grid and display the new row.

Keep in mind that the dojox.grid package is outdated, and it's recommended to use the newer dgrid package for more modern grid functionality in Dojo.


原文地址: https://www.cveoy.top/t/topic/pZOD 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录