Framework: SPRING 3.06 + DOJO 1.7
<script type="text/javascript">function prepareDatagrid(){
require(['dojox/grid/DataGrid', 'dojox/data/JsonRestStore'],
function(DataGrid, JsonRestStore)
{
console.log("showCollegeBlock.jsp");
console.log("${urlCollegeHouses}");
gridLayout = [
{ name: 'Code', field: 'id.chmHouseCode', editable: true},
{ name: 'Name', field: 'chmHouseDesc'},
{ name: 'Capacity', field: 'chmCapacity'}];
var poStore = new JsonRestStore({target: "${urlCollegeHouses}/ajaxUnits/${hostelId}?" });
// use the query results returned from the server
/*create a new grid*/
var grid = new DataGrid({
id: 'grid',
store: poStore,
structure: gridLayout,
rowSelector: '20px'});
/*append the new grid to the div*/
grid.placeAt("gridDiv");
/*Call startup() to render the grid*/
grid.startup();
});}
</script>
Selain itu boleh guna kaedah manual fetching:
poStore.fetch({
onComplete: function(items){
grid = new dojox.grid.DataGrid({
store: poStore,
items: items,
structure: gridLayout
}, "gridDiv");
grid.startup();
}
});
No comments:
Post a Comment