Hi, I'm using Dgrid to display Query Results. I want to dynamic add feature data to store. Here is two code paragraphs:
First Code:
var typesData = []; for (var i = 0; i < 5; i++) { var j ={ objectid: results.features.attributes.objectid, madvhc: results.features.attributes.madvhc, ten: results.features.attributes.ten, tinh: results.features.attributes.tinh, diachi: results.features.attributes.diachi, macosoyte: results.features.attributes.macosoyte, macsyt1: results.features.attributes.macsyt1, loaihinhcsyt: results.features.attributes.loaihinhcsyt, huyen: results.features.attributes.huyen, matinh: results.features.attributes.humatinhyen, mahuyen: results.features.attributes.mahuyen, tuyencsyt: results.features.attributes.tuyencsyt, kinhdo: results.features.attributes.kinhdo, vido: results.features.attributes.vido, xaphuong: results.features.attributes.xaphuong, filegoc: results.features.attributes.filegoc, namdieutra: results.features.attributes.namdieutra }; typesData.push(j); }
Second Code:
var typesData = []; for (var i = 0; i < 5; i++) { typesData.push(results.features.attributes); }
The first and the second have the same number of fields but the first can display with right row value in grid when selected, the second only get the last row value in grid when selected. I cannot find what is a problem. Please help me.
What kind of dgrid are you using. To be able to dynamically add results you need to use OnDemandGrid.
Could you let us know what you mean by "when selected". Also share screen shot and code, where you assign the typesData to dgrid. may be the issue is not how you are creating the data store. but rather how it is assigned.
Thank you, thesus,
I'm already done with it. May be my objectid field has problem. When i change from 'objectid' to 'id' name, everything's running ok.
Regards.