I am working with an existing website that I did most of the code on. It is a Emergency Operations Center website with automatic vehicle tracking as well as history queries. I was able to query the history for the vehicles with no problem, but I am now trying to query the history of the 911 calls and am coming across some issues. Any help is greatly appreciated!
Here is the code I am working with:
window.Calls911HistoricalUrl = "http://gis10204:6080/arcgis/rest/services/GeoEvent/AVL_911_Historical_WebOut/FeatureServer/0";
window.Calls911HistoricalOutFields = ["PhoneNumber", "CallType", "TimeStamp"];
registry.byId("execute911bynumber").on("click", execute911bynumber);
function execute911bynumber(){
var queryTask = new QueryTask(window.Calls911HistoricalUrl);
var query = new Query();
query.returnGeometry = false;
query.outFields = window.Calls911HistoricalOutFields;
query.where = "PhoneNumber = " +"'"+number+"'";
queryTask.execute(query, function(results) {
var data = [];
var data = array.map(results.features, function(feature) {
return {
//property names used here match those used when creating the dgrid
"Phonenumber": feature.attributes[window.Calls911HistoricalOutFields[0]],
"Calltype": feature.attributes[window.Calls911HistoricalOutFields[1]],
"Timereceived": feature.attributes[window.Calls911HistoricalOutFields[2]]
}
});
var memStore = new Memory({ data: data });
//create historical data dgrid
window.grid2 = new (declare([OnDemandGrid, Selection]))({
bufferRows: Infinity,
store:memStore,
maxRowsPerPage: 5000,
columns: {
"Phonenumber": "Phone Number",
"Calltype": "Call Type",
"Timereceived": {"label": "Time Received", "formatter": formatTimestamp}
},
loadingMessage: "Loading data...",
noDataMessage: "No records found."
}, "grid2");
grid2.set("sort", [{attribute:"Timereceived", descending:true}]);
});
grid2.setStore();
}The html code is as follows:
<div data-dojo-type="dijit/layout/ContentPane" id="911historyPane"
data-dojo-props="title:'911 History'" style="background-color:#bee8ff;">
<div>
Phone Number: <input type="text" id="number" size="20">
</div>
<div>
Start Date & Time: <input id="911date" type="text" size="20"><a href="javascript:NewCal('911date', 'mmddyyyy')"><img src="images/cal.gif" width="18" height="18" border="0"></a>
</div>
<div>
End Date & Time: <input id="911date2" type="text" size="20"><a href="javascript:NewCal('911date2', 'mmddyyyy')"><img src="images/cal.gif" width="18" height="18" border="0"></a>
</div>
<div>
<button id ="execute911bydate" data-dojo-type="dijit.form.Button" type="button" data-dojo-attach-point="button" title="Search By Date">Search By Date
</button>
<button id ="show911" data-dojo-type="dijit.form.Button" type="button" data-dojo-attach-point="button" title="Show on Map" >Show on Map
</button>
<button id ="clear911" data-dojo-type="dijit.form.Button" type="button" data-dojo-attach-point="button" title="Clear" >Clear History
</button>
</div>
<div>
<button id="execute911bynumber" data-dojo-type="dijit.form.Button" type="button" data-dojo-attach-point="button" title="Search By Number"> Search By Number
</button>
<button dojotype="dijit.form.Button" id="911historyHelp" title="Help">
<img src="images/Help.png" width=15px height=15px/>
</button>
</div>
<div id="grid2" class="claro"></div>
</div>I was able to search on date alone and come up with the correct information, but when I try and search on phone number alone, I am getting no results even though I know that there are at least 5 calls for that phone number. I have also tried using query.text = dom.byId("number").value; but using that throws an error, "unable to complete operation". Again, any help figuring this out is greatly appreciated.
Michelle