Select to view content in your preferred language

Populate dataGrid with Query Results

1177
4
08-16-2012 12:29 PM
DonCaviness
Occasional Contributor
I am trying to populate a dataGrid with results from a query and I've run into an issue.  I have used the sample http://help.arcgis.com/en/webapi/javascript/arcgis/demos/fl/fl_zoomgrid.html and have been able to get it to work as a stand alone sample, however that doesn't help with my project.  In my project I am dynamically creating the html table that will be the dataGrid: 
html += '<div id="bufferResultsDiv" data-dojo-type="dijit.layout.ContentPane" class="Pad" style="Display: none;">';
 html += '<table data-dojo-type="dojox.grid.DataGrid" data-dojo-id="grid"  id="grid" data-dojo-props="rowsPerPage:"5", rowSelector:"20px">';
  html += '<thead>';
      html += '<tr>';
          html += '<th field="parcel_f" width="100%">Parcel #</th>';
          html += '<th field="name1" width="100%">Name</th>';
      html += '</tr>';
  html += '</thead>';
 html += '</table>';
html += '</div>';
$('#parcelSearchControls').html(html);
I get an error saying that .setStore is not a function at this line:
grid.setStore(store);
I have tried declare the grid multiple ways:
var grid = dijit.byId('grid');
var grid = dojo.byId('grid');
var grid = $("#grid");


Does anyone have any suggestions on what I can do to populate my dataGrid?
0 Kudos
4 Replies
__Rich_
Deactivated User
I don't tend to inject HTML this way when creating dijits but just a guess, do you need to run the dojo parser over the newly injected markup to get it to create the DataGrid dijit?

Otherwise, why not just create the grid programmatically and place it in the DOM?

HTH
0 Kudos
DonCaviness
Occasional Contributor
As far as running the dojo parser again I'm not positive.  Maybe someone with more knowledge with dojo can answer that.  I am interested in your suggestion.  How would I go about creating the dataGrid programmatically and placing it in the DOM?  Do you have any examples of what you are suggesting?
0 Kudos
__Rich_
Deactivated User
As far as running the dojo parser again I'm not positive.  Maybe someone with more knowledge with dojo can answer that.

If you're dynamically injecting markup containing dojo widgets into the page post rendering and after (if you set parseOnLoad:true) the parser has already run then how would it know about your new widget?
Suggest you have a read here:

dojo-parser

I am interested in your suggestion.  How would I go about creating the dataGrid programmatically and placing it in the DOM?  Do you have any examples of what you are suggesting?


There's a programmatic example here:

dojox-grid-datagrid

(note that this grid has been deprecated in favour of dgrid)
0 Kudos
DonCaviness
Occasional Contributor
Thank you for the suggestion.  However, I had already figured it out.
0 Kudos