Hide Table of Contents
View DataReviewer - Dashboard Results with Filter sample in sandbox
DataReviewer - Dashboard Results with Filter


This sample shows how to fetch and display a filtered dashboard summary from a Reviewer dataset. The summary is total counts of a value in the specific or custom (user-defined) fields in the Reviewer dataset's REVTABLEMAIN or REVBATCHRUNTABLE tables. The summary displays the number of occurrences of a unique value in a field in these tables. This sample filters dashboard summary with an instance of ReviewerFilters. The ReviewerFilters instance contains one or more attribute filters depending on what values the user selects in the UI. Filters added to a ReviewerFilters instance work like a query. The live sample retrieves dashboard summary from a hosted instance of Data Reviewer for Server.


<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Dashboard Get Results with Attribute Filter Sample</title>    
<link rel="stylesheet" href="https://js.arcgis.com/3.38/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.38/dojox/grid/resources/claroGrid.css">
<script src="https://js.arcgis.com/3.38/"></script>
 .reviewerGrid {
   font-size: 0.75em;
   font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
.reviewerForm {
	width: 530px;
	font-size: .7em;
	font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
.submitButton {
	float: right;
	padding: 5px;
	width: 150px;
	font-size: 1.1em;
	border: 2px solid #CCC;
	margin: 0px 0px 10px 0px;
label {
	float: left;
	text-align: right;
	margin-right: 15px;
	width: 130px;
	padding-top: 5px;
	padding: 5px;
	width: 385px;
	margin: 0px 0px 10px 0px;
	border: 2px solid #CCC;
.message {
	float: right;
	padding: 5px;
	width: 280px;

	float: right;
	padding: 5px;
	width: 280px;
	color: #C41111;
  //This should point to the Data Reviewer soe
  var drsSoeUrl = "https://datareviewer.arcgisonline.com/arcgis/rest/services/Samples/reviewerDashboard/MapServer/exts/DataReviewerServer";
  var dashboardTask;
  var reviewerFilters;
  function( parser, on, dom, query, registry, array, DashboardTask, ReviewerFilters, Chart, Pie, Distinctive, DataGrid, ItemFileReadStore) {
    // specify proxy for request with URL lengths > 2k characters
    esriConfig.defaults.io.proxyUrl = "/proxy/";
     // create a new DashboardTask with the DRS SOE URL
     dashboardTask = new DashboardTask(drsSoeUrl);
     //Retrieve Dashboard FieldNames and 
     //Create radio buttons
     var count = 1;
        array.forEach(fieldNames.fieldNames, function(fieldName, i) {
            dom.byId("dashboardFieldNamesCombo")[i] = new Option( fieldName, fieldName); 
     // handle getResults button click event
     on(dom.byId("getResultsButton"), "click", function(evt) {
     // handle the filter checkboxes click event
     on(query('[name=\"chkBoxGroup\"]'), "click", applyAttributeFilters);

     function getDashboardResults(reviewerFilters) {
        //Identify the Dashboard field that user has selected 
        var selectedField = dom.byId("dashboardFieldNamesCombo").value;
        // retrieve the results by user selected field
        if((reviewerFilters !== undefined) && (reviewerFilters !== null) && (reviewerFilters.getCount() >0))
            dashboardTask.getDashboardResults(selectedField, reviewerFilters);	

           // make content visible
           dom.byId("mainContent").style.visibility = "visible";

           // now process the response, this is necessary because the
           // dojo chart expects an array of key-value pairs in the
           // format of [{text:<label>,y:<value>}]
           var mappedArray = [];
           array.forEach(response.dashboardResult.fieldValues, function(item, i) {
                 text : item,
                 y : response.dashboardResult.getCount(item)

           // update the chart
           var chart = registry.byId("chart").chart;
           chart.addSeries("reviewer", mappedArray);

           //set datagrid layout
           var gridLayout=[[
               {field: 'text', name: selectedField, width:'250px'},
               {field: 'y', name: 'COUNT', width:'100px'}

           //creating store for datagrid
           var store = new ItemFileReadStore({
              data : {
                 items : mappedArray
           // update the datagrid
           var grid = registry.byId("dashBoardResultsGrid");
        dashboardTask.on("error", function(error) {
           var grid = registry.byId("dashBoardResultsGrid");
           showMessage("dashboardMessages", "Error occurred  " + error.error.message, "errorMessage");
     //error handling
     function showMessage(divName, text, className) {
        var messageDiv = dom.byId(divName);
        messageDiv.innerHTML = "";
        messageDiv.className = className || "";
        messageDiv.innerHTML = text;
     // Add reviewer filters
     function applyAttributeFilters(evt) {
        // create a new ReviewerFilters instance
        reviewerFilters = new ReviewerFilters();
        query('[name=\"chkBoxGroup\"]').forEach(function(chkbox) {
           if(chkbox.checked) {
              // populate the ReviewerFilters instance with
              //  attributeFilters (by severity in this case)
              reviewerFilters.addAttributeFilter("SEVERITY", parseInt(chkbox.value));
        //check if there is at least one filter
        if(reviewerFilters.getCount() > 0)
<body class="claro">
<h2 align="center">Dashboard Get Results with filters Sample</h2>
    <div style="width:100%; overflow-x: auto;" >
        <div style="padding: 0px 20px 0px 0px; float:left;">
            <div class="reviewerForm" >
                <label for="dashboardFieldNamesCombo">Dashboard results by:</label>
                <select id="dashboardFieldNamesCombo"></select>
                <button id="getResultsButton" title="GetResults" class="submitButton">Get Dashboard Results</button>	
                <div id="dashboardMessages" class="message"></div>
  <div id="mainContent" style="width:100%;visibility: hidden">
     <div style="width: 100%; padding-bottom: 20px" class="label">
        <div style="margin-bottom: 15px"  >
           Filter dashboard results by Severity
        <input type="checkbox" value="1" name="chkBoxGroup" />
        Severity 1  
        <input type="checkbox" value="2" name="chkBoxGroup" />
        Severity 2  
        <input type="checkbox" value="3" name="chkBoxGroup" />
        Severity 3  
        <input type="checkbox" value="4" name="chkBoxGroup" />
        Severity 4  
        <input type="checkbox" value="5" name="chkBoxGroup" />
        Severity 5  
     <div id="chart" title="Distribution of Reviewer results"
     style="width: 500px; height: 400px; float:left;" >
        <div class="plot" name="default" type="Pie" radius="120" fontColor="#000" labelStyle="default" labelOffset="-30"></div>
     <div style="padding: 0px 20px 0px 20px; float:left;">
        <table id="dashBoardResultsGrid" columnReordering="false"
        data-dojo-type="dojox/grid/DataGrid"  autoHeight="true" autoWidth="true" class="reviewerGrid">
Show Modal