0

在这个例子中:

function onRowClickHandler(evt){
    var clickedTaxLotId = grid.getItem(evt.rowIndex).PARCELID;
    var selectedTaxLot;

    dojo.forEach(map.graphics.graphics,function(graphic){
      if((graphic.attributes) && graphic.attributes.PARCELID === clickedTaxLotId){
        selectedTaxLot = graphic;
        return;
      }
    });
    var taxLotExtent = selectedTaxLot.geometry.getExtent();
    map.setExtent(taxLotExtent);
  }

他们从这里选择 PARCELID:

      <th field="PARCELID">Parcel ID</th>
      <th field="OWNERNME1" >Owner 1</th>
      <th field="OWNERNME2">Owner 2</th>
      <th field="RESYRBLT ">Year Built</th>
      <th field="SITEADDRESS" width="100%">Address</th>

但现在我的问题是我有一个<th field="1">不可改变的。但我需要得到这样的值, var clickedTaxLotId = grid.getItem(evt.rowIndex).2;但在 javascript 中这是不可能的。

表头如下所示:

 <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'bottom'" style="height:350px;" >
<table data-dojo-type="dojox.grid.DataGrid" jsid="grid" id="grid" data-dojo-props="rowsPerPage:'5', rowSelector:'20px'">
  <thead>
    <tr>

      <th field="0" width="auto" >
        Gezocht op
      </th>
      <th field="1" width="auto" >
        Gevonden
      </th>

    </tr>
  </thead>
</table>

编辑

在这里,我设置了第 th 字段的值。这由 dataForGrid 完成。第一个字段是“0”,并用 result.foundFieldName 填充,“1”用 result.value

 map.graphics.clear();
    var dataForGrid = [];
    //Build an array of attribute information and add each found graphic to the map
    dojo.forEach(results, function(result) {
      var graphic = result.feature;
      dataForGrid.push([result.foundFieldName, result.value]);
      var userlabel = result.value;
      switch (graphic.geometry.type) {
      case "point":
        graphic.setSymbol(markerSymbol);
        break;
      case "polyline":
        graphic.setSymbol(lineSymbol);
        break;
      case "polygon":
        graphic.setSymbol(polygonSymbol);
        break;
      }
      map.graphics.add(graphic);
    });
    var data = {

      items: dataForGrid
    };
    var store = new dojo.data.ItemFileReadStore({
      data: data
    });
    grid.setStore(store);
  }
4

0 回答 0