简体   繁体   中英

gridx shows the last record of my dynamic data

你好,我正在使用网格显示动态数据dojo,但是我得到的是该样本(n)次,但总是显示最后一条记录,但是如果我对虚拟数据进行处理的话,我希望您能为我解决这个问题。

define(["js/module/modControllerPersona", "dojo/store/Memory", "gridx/Grid", "gridx/core/model/cache/Sync", "dojo/data/ObjectStore"], function(modControllerPersona, Store, Grid, Cache, ObjectStore){ var grid, store, data; var persona = new Array(); return{ datagridx: function(){ modControllerPersona.persona().then(function(result){ persona = JSON.parse(result); data = persona.items; store = new Store({data: data}); var columns = [ {name: 'id', field: 'descripcion'}, {name: 'descripcion', field: 'id_Maquinaria'}, {name: 'descripcion', field: 'id_tipo_Maquinaria'}, {name: 'Nombre', field: 'kind'}, {name: 'Nombre', field: 'nombre'}, {name: 'Nombre', field: 'visible'} ]; grid = new Grid({ cacheClass: Cache, store: store, structure:columns }, 'gridNode'); grid.startup(); });

Perhaps this can help you, I had a similar problem. If you don't have a column id it doesn't work right. But if you adjust your store to something like this:

var store = new Memory({
    data:           data,
    idProperty:     'descripcion'
});

Perhaps the "new Memory" is not necassary. In my case this works (but I didn't tested it here again). I have no id but I have another unique field instead of this. I suppose it is because of your

{name: 'id', field: 'descripcion'}

If you use instead of "descripcion" the name "id" I think it should work too.

Just add "idProperty" for Gridx, I solved my problem

My dynamic data: var data = [{"ID":"1","Số liệu thống kê":"Năng suất lập trình","Ngôn ngữ LT":"Java Web","Công đoạn":"Code - Review Code","Loại Project":"Customize/Full","Đơn vị tính":"KLOC/ManMonth","UCD1":"11.6","ITS":null},{"ID":"2","Số liệu thống kê":"Năng suất lập trình","Ngôn ngữ LT":"Java Web","Công đoạn":"Code - Review Code - UT","Loại Project":"Customize/Full","Đơn vị tính":"KLOC/ManMonth","UCD1":"4.6","ITS":null},{"ID":"3","Số liệu thống kê":"Năng suất lập trình","Ngôn ngữ LT":"Java Web","Công đoạn":"Code","Loại Project":"Customize/Full","Đơn vị tính":"KLOC/ManMonth","UCD1":"15.15","ITS":null}];

require([ 'dojo/store/Memory', 'gridx/Grid', 'gridx/core/model/cache/Sync' ], function (Memory, Grid, Cache) { var store = new Memory({ data: data, idProperty: 'ID' }); Hope this help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM