関連する行がクリックされると、dojo.gridx テーブルに格納されているデータ値を取得しようとしています。次の関数が最初に呼び出される限り正常に機能し、その関数が新しいデータで再度呼び出されると、それらのデータは画面に正しく表示されますが、任意の行をクリックすると、取得される実際のデータはその行に属するものです関数が最初に呼び出されたときにロードされたデータを保持します。正しいデータを取得する唯一の方法は、Java スクリプトを呼び出して HTML ページ全体をリロードすることです。「dati」としてロードされたデータは、ここには示されていない ajax-js から動的に取得されます。
HTML reference:
<table data-dojo-type="gridx.Grid" id="userconf" selectable="true" selectionMode="single" singleClickEdit="true" style="width: 936px; position: absolute; z-index: 900; left: 23px; top: 280px; height: 170px;" data-dojo-props="cacheClass: 'gridx/core/model/cache/Async',store:ItemFileWriteStore_11">
<thead>
<tr>
<th field="cf_utente" width="auto" editable="true" type="dojox.grid.cells.Bool">
cf_utente</th>
<th field="sn_contatore" width="auto" editable="true" type="dojox.grid.cells.Bool">
sn_contatore</th>
<th field="sn_serbatoio" width="auto" editable="true" type="dojox.grid.cells.Bool">
sn_serbatoio</th>
<th field="seqnum" width="auto" editable="true" type="dojox.grid.cells.Bool">
seqnum</th>
</tr>
</thead>
</table>
jscript:
function fillupAnagUsers(dati) {
var grid = dijit.byId('userconf');
var rows = dati.split("\n");
var righe = [];
var data = {items: righe};
var i,j,rw,x;
var lbl = rows[0].split(",");
var newStore = new dojo.data.ItemFileWriteStore({data: data});
for(i=1;i<rows.length-1;i++) {
rw = rows[i].split(",");
x = "{";
for(j=0;j<lbl.length-1;j++) {
x +=lbl[j]+":\""+rw[j]+"\",";
}
x += lbl[j]+":\""+rw[j]+"\"}";
eval('var obj='+x);
data.items.push(obj);
}
grid.setStore(newStore);
var handle = dojo.connect(grid, "onCellClick", grid, function(evt){
var idx = evt.rowIndex;
var data = this.cell(idx, 0).data();
dojo.byId('cfutente').value = data.substring(data.indexOf('r>')+2,data.indexOf('</'));
data = this.cell(idx, 1).data();
dojo.byId('sncontatore').value = data.substring(data.indexOf('r>')+2,data.indexOf('</'));
data = this.cell(idx, 2).data();
dojo.byId('snserbatoio').value = data.substring(data.indexOf('r>')+2,data.indexOf('</'));
data = this.cell(idx, 3).data();
dojo.byId('useqnum').value = data.substring(data.indexOf('r>')+2,data.indexOf('</'));
dojo.byId('rec').value = dojo.byId('useqnum').value;
});
}