Select to view content in your preferred language

Using substring to query, show result in datagrid

1034
4
06-02-2011 12:46 AM
hayaticm
Emerging Contributor
Hi,

I have a spatial layer which is join with a table, therefore all the field name will be in substring like PAD.LP_PD.OBJECTID.

I have no issue to run query from the substring, but i am stuck at function to zoom to selected feature/polygon when user click a row in datagrid(result from query).

Below is the code:

//Zoom to the parcel when the user clicks a row
function onRowClickHandler(evt){
var OBJECTID = ("PAD.LP_PAD.OBJECTID");
var clickedTaxLotId = grid.getItem(evt.rowIndex).OBJECTID;

var selectedTaxLot;

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

I have tried using this declaration:
var clickedTaxLotId = grid.getItem(evt.rowIndex).(PAD.LP_PAD.OBJECTID);
var clickedTaxLotId = grid.getItem(evt.rowIndex).valueOf(PAD.LP_PAD.OBJECTID);

but those two declaration will take the whole result in datagrid, not the exact selected row.
Please advice..
Suggestion is highly appreciated.
0 Kudos
4 Replies
HemingZhu
Frequent Contributor
Hi, 

I have a spatial layer which is join with a table, therefore all the field name will be in substring like PAD.LP_PD.OBJECTID. 

I have no issue to run query from the substring, but i am stuck at function to zoom to selected feature/polygon when user click a row in datagrid(result from query). 

Below is the code: 

//Zoom to the parcel when the user clicks a row 
function onRowClickHandler(evt){ 
   var OBJECTID = ("PAD.LP_PAD.OBJECTID");
var clickedTaxLotId = grid.getItem(evt.rowIndex).OBJECTID;

var selectedTaxLot; 

dojo.forEach(map.graphics.graphics,function(graphic){ 
if((graphic.attributes) && graphic.attributes.OBJECTID === clickedTaxLotId){ 
selectedTaxLot = graphic; 
return; 

}); 
var taxLotExtent = selectedTaxLot.geometry.getExtent(); 
map.setExtent(taxLotExtent); 


I have tried using this declaration: 
var clickedTaxLotId = grid.getItem(evt.rowIndex).(PAD.LP_PAD.OBJECTID); 
var clickedTaxLotId = grid.getItem(evt.rowIndex).valueOf(PAD.LP_PAD.OBJECTID); 

but those two declaration will take the whole result in datagrid, not the exact selected row. 
Please advice.. 
Suggestion is highly appreciated.


Try this: either change clickedTaxLotId = grid.getItem(evt.rowIndex).OBJECTID to clickedTaxLotId = grid.getItem(evt.rowIndex).OBJECTID[0], or loose up the comparsion graphic.attributes.OBJECTID === clickedTaxLotId to graphic.attributes.OBJECTID == clickedTaxLotId
0 Kudos
hayaticm
Emerging Contributor
Try this: either change clickedTaxLotId = grid.getItem(evt.rowIndex).OBJECTID to clickedTaxLotId = grid.getItem(evt.rowIndex).OBJECTID[0], or loose up the comparsion graphic.attributes.OBJECTID === clickedTaxLotId to graphic.attributes.OBJECTID == clickedTaxLotId


Tried both..it does not working. Seems like does not know/understand OBJECTID because the field is called PAD.LP_PAD.OBJECTID. if no substring used (spatial does not join with other table), then I can use OBJECTID only
0 Kudos
HemingZhu
Frequent Contributor
Tried both..it does not working. Seems like does not know/understand OBJECTID because the field is called PAD.LP_PAD.OBJECTID. if no substring used (spatial does not join with other table), then I can use OBJECTID only


You can look at your service directory to see how the field names are listed. if the field listed as PAD.LP_PAD.OBJECTID, then the statement should be  clickedTaxLotId = grid.getItem(evt.rowIndex).PAD.LP_PAD.OBJECTID[0]. the best way to find out is to debug the statement.
0 Kudos
hayaticm
Emerging Contributor
You can look at your service directory to see how the field names are listed. if the field listed as PAD.LP_PAD.OBJECTID, then the statement should be  clickedTaxLotId = grid.getItem(evt.rowIndex).PAD.LP_PAD.OBJECTID[0]. the best way to find out is to debug the statement.


Thanks for your advice, have to try to debug the code.
0 Kudos