<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Issues with dgrid Selection, only selected records are shown, can't restore in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-dgrid-selection-only-selected-records/m-p/444817#M41085</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I thought it might be an issue with the selectors not being cleared when the selection is cleared from this &lt;A href="https://github.com/SitePen/dgrid/issues/653"&gt;issue&lt;/A&gt;‌, but adding a Clear All button to the Selector &lt;A href="http://dojofoundation.org/packages/dgrid/js/dgrid/test/selector.html"&gt;test code&lt;/A&gt; (the full list of dGrid tests is &lt;A href="http://dojofoundation.org/packages/dgrid/js/dgrid/test/"&gt;here&lt;/A&gt;) seems to work perfectly fine. You can see the code &lt;A href="http://jsbin.com/levina/1/edit?html,output"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 08 Sep 2014 15:09:33 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2014-09-08T15:09:33Z</dc:date>
    <item>
      <title>Issues with dgrid Selection, only selected records are shown, can't restore</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-dgrid-selection-only-selected-records/m-p/444815#M41083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a dGrid declared with both Selection and selector, to have check boxes for each row.&amp;nbsp; I let the user select multiple rows and use those to create a chart.&amp;nbsp; In addition, if they click on a single feature on the map, this also creates a chart for just that feature.&amp;nbsp; This is all working, my problem is with what is happening to my grid.&amp;nbsp; Once I've gone through the process of creating my chart, either from the grid selection, or the click on the featureLayer, my grid only contains the selected records I used for the chart and nothing else.&amp;nbsp; I can't figure out how to get my grid back to it's previously unselected, all records original.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is how I'm creating my grid.&amp;nbsp; It's generated as a results handler on a featureLayer.queryFeatures where the query contains a where clause of 1=1, so it returns all records. My grid has the correct data in it and shows all records. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The grid doesn't have hard coded column names.&amp;nbsp; I have a function that builds the columns from an array of field names I define earlier.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14099245304364961 jive_text_macro" jivemacro_uid="_14099245304364961" modifiedtitle="true"&gt;
&lt;P&gt;function createGrid(results) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; domConstruct.empty(dom.byId('gridDiv'));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var gridColumns = buildColumns();&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var data = arrayUtils.map(results.featureSet.features, function(feature){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return feature.attributes;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; });&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var currentMemory = new Memory ({data:data, idProperty:'OBJECTID'}); &lt;/P&gt;
&lt;P&gt;&amp;nbsp; grid = new (declare([Grid, Selection, selector]))({&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id:'grid', &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; columns: gridColumns, &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selectionMode:'single',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; store: currentMemory&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, "gridDiv"); &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; grid.sort('County');&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;//creates a column definition for the grid based on the attributes returned from the query&lt;/P&gt;
&lt;P&gt;&amp;nbsp; function buildColumns() {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var columns = [];&lt;/P&gt;
&lt;P&gt; //qryOutFields is an array of fieldNames defined earlier&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayUtils.forEach(qryOutFields, function(field){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var objects = {};&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; objects.label = field;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; objects.field = field;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (field === 'OBJECTID') {//assumed name for internal ID from map service&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; objects.hidden = true;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; columns.push(objects);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var sel = selector({ label: '', sortable: false });&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; columns.splice(0, 0, sel);&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return columns;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Make Chart button executes the function getIdFromGrid, checks to see what's currently selected in the grid, gathers the objectids and county names.&amp;nbsp; The initializeChart uses those objectIDs to execute another query to get the attributes for those records.&amp;nbsp;&amp;nbsp; These become the input needed for the chart (the lists of rates and the maximum value for the Y axis)&amp;nbsp; Last, it calls a function to finish the chart. &lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1409924976717670 jive_text_macro" jivemacro_uid="_1409924976717670" modifiedtitle="true"&gt;
&lt;P&gt;function getIdFromGrid(){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var rowid,gQuery;&lt;/P&gt;
&lt;P&gt;idList.length = 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; countyList.length = 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; maxList.length = 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (var rowid in grid.selection) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var row = grid.row(rowid);&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; idList.push(parseFloat(rowid));&amp;nbsp; //list of objectIds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; countyList.push(row.data.County);&amp;nbsp; // list of county names&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; initializeChart();&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;function initializeChart(){&lt;/P&gt;
&lt;P&gt; // console.log("county list = " + countyList);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; domConstruct.empty("chartDiv");&lt;/P&gt;
&lt;P&gt;&amp;nbsp; lineChart = new Chart2D("chartDiv");&lt;/P&gt;
&lt;P&gt;&amp;nbsp; gQuery = new Query();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; gQuery.objectIds = idList;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; seriesList.length = 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; featureLayer.queryFeatures(gQuery, function(results) {&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayUtils.forEach(results.features, function (result){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; createRateList(result);//builds an array of attributes for each records&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; });&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var maxRate = findMax(maxList);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var maxVal = Math.round(maxRate);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var axisYMax =&amp;nbsp; (parseInt(maxVal/10)+1)*10; //extends the Y axis to an even interval&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; finishLineChart(axisYMax);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;In finishLineChart, my chart gets created.&amp;nbsp;&amp;nbsp; That function is rather long, so I'm leaving it out.&amp;nbsp; Once the chart is displayed, the grid changes.&amp;nbsp; It only includes the selection made when I executed Make Chart. I can't figure out how to get back to the 'unselected' state.&amp;nbsp; I have a clear button where I'm attempting to get rid of everything I can think of.&amp;nbsp; I've thought of running another query of '1=1' just to select all my features again, but that seems extreme.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14099242266622211" jivemacro_uid="_14099242266622211" modifiedtitle="true"&gt;
&lt;P&gt;&amp;nbsp; registry.byId('btnClearChart').on('click', function (){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; grid.clearSelection();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; featureLayer.clearSelection();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; grid.refresh();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt; }); &lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there some other method of clearing out my grid selection and getting back to the original?&amp;nbsp; I've used grids in nearly every map I've created, but this is the first time I've used either Selection or selector.&amp;nbsp; I'm wondering if there is something buggy in other of those?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2014 14:14:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-dgrid-selection-only-selected-records/m-p/444815#M41083</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2014-09-05T14:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with dgrid Selection, only selected records are shown, can't restore</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-dgrid-selection-only-selected-records/m-p/444816#M41084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tracy,&lt;/P&gt;&lt;P&gt;dgrid would refresh only when you change it's store, with new data. I don't see that happening in the code you have posted.&lt;/P&gt;&lt;P&gt;I would recommend you to sweep through the code to double check if you are overriding your grid's store property. Look for "&lt;STRONG&gt;.store =&lt;/STRONG&gt; " and &lt;STRONG&gt;setStore &lt;/STRONG&gt;in your code this is how you could override your grid's store.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My prime suspect is your createRateList function. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Sep 2014 12:11:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-dgrid-selection-only-selected-records/m-p/444816#M41084</guid>
      <dc:creator>RiyasDeen</dc:creator>
      <dc:date>2014-09-06T12:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with dgrid Selection, only selected records are shown, can't restore</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-dgrid-selection-only-selected-records/m-p/444817#M41085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I thought it might be an issue with the selectors not being cleared when the selection is cleared from this &lt;A href="https://github.com/SitePen/dgrid/issues/653"&gt;issue&lt;/A&gt;‌, but adding a Clear All button to the Selector &lt;A href="http://dojofoundation.org/packages/dgrid/js/dgrid/test/selector.html"&gt;test code&lt;/A&gt; (the full list of dGrid tests is &lt;A href="http://dojofoundation.org/packages/dgrid/js/dgrid/test/"&gt;here&lt;/A&gt;) seems to work perfectly fine. You can see the code &lt;A href="http://jsbin.com/levina/1/edit?html,output"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Sep 2014 15:09:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-dgrid-selection-only-selected-records/m-p/444817#M41085</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2014-09-08T15:09:33Z</dc:date>
    </item>
  </channel>
</rss>

