Skip to main content

I am wanting to bring in data from different models in a tabular format.  It’s seems tricky (if at all possible) using the table component but I can using the template module ensuring I order the model the same for each one - each template component is places side by side to represent the table format,

I am wanting to have a count function against a name.  However, if there are no records associated with one person, it misses the row out completely showing less rows and thus messing with the format

Is it possible for it too show 0 instead of missing the row out completely?

Hope that makes sense?

Chris,

I dealt with the same issue with aggregate models not including a row if the value was zero. I resorted to using javascript to run through the rows of the model and add the missing rows.

You may also want to consider using the table component and creating your own dynamic model for the table. Then you can use adoptRows() to pull rows into your model from your other models.


Thanks Matt, don’t suppose you have any examples of the javascript to add the missing rows?



Here’s something of a sample.
This is part of some code to allow us to ‘aggregate’ on distinct value of a multipicklist field. Before this code, we’ve calculated the values that we want in each row and stored them in a javascript object called ‘totalEthnicity’. We’re emptying the model “mdlEthnicity” and then adding back all the rows that we want (even if the value is 0). Our grouping field on the model is called grpCategories and our aggregation field is totalRecords.


&#47;&#47; clear the model&#46;<br />&nbsp; &nbsp; &nbsp;&nbsp; $&#46;each(mdlEthnicity&#46;getRows(), function(i, row) {<br /> &nbsp; &nbsp; &nbsp; mdlEthnicity&#46;abandonRow(row);<br /> &nbsp; &nbsp; &nbsp; });<br /> &nbsp; &nbsp; &nbsp; &#47;&#47; create an array of all of the new rows to be added back to the model for displaying&#46;<br /> &nbsp; &nbsp; &nbsp; var newRows = s<br />{ grpCategories: "Unknown", totalRecords: totalEthnicity&#46;unknown },<br />{ grpCategories: "Hispanic Or Latino", TotalRecords: totalEthnicity&#46;HispanicOrLatino},<br />{ grpCategories: "American Indian or Alaska Native", TotalRecords: totalEthnicity&#46;AmericanIndianOrAlaskanNative },<br />{ grpCategories: "Asian", TotalRecords: totalEthnicity&#46;Asian },<br />{ grpCategories: "African American", TotalRecords: totalEthnicity&#46;AfricanAmerican },<br />{ grpCategories: "Native Hawaiian or Pacific Islander", TotalRecords: totalEthnicity&#46;NativeHawaiianOrOtherPacificIslander },<br />{ grpCategories: "Caucasian", TotalRecords: totalEthnicity&#46;Caucasian },<br />{ grpCategories: "Other", TotalRecords: totalEthnicity&#46;Other },<br />{ grpCategories: '', TotalRecords: totalValues }<br /> &nbsp; &nbsp; &nbsp; ];<br /> &nbsp; &nbsp; &nbsp; &#47;&#47; add the rows to the model, then rerender the table for displaying&#46;<br />mdlEthnicity&#46;adoptRows( newRows, { doAppend: true });<br /> &nbsp; skuid&#46;component&#46;getById('EthnicityInformationTable')&#46;render(); 



There may be an “empty model” method, but it’s not published in the documentation, so we’re using abondonRow() instead.

Hope that helps!

You should be able to adopt as many fields and rows as you’d like into your model.