Need help with getting data from a Zen page property and setting column widths in my dynaGrid
Given the code below, I need help with getting the collected column widths from the Demo.Configuration table and stored in the columnWidths zne page property. As I understand it, I should be able to retrieve it using zenPage.columnWidths in the setColumnWidths or dgRender clientMethods but the alert is showing that it cannot be retrieved as it shows a value of Null. Once I can retrieve those values, then I want to set the widths of the colmns of the dynaGrid according to the values in the ^Demo.Configuration table. The data pulled in from the CSV file that creates ^Demo.Import can have a different included columns depending on the choices of the user.
/// Created using the page template: Title Page
Class Demo.DynaGrid Extends %Z
{
/// Displayed name of this page.
Parameter PAGENAME = "DynamicDynaGrid";
/// Property to hold column widths
Property columnWidths As %ZEN.Datatype.string;
/// This Style block contains page-specific CSS style definitions.
XData Style
{
<style type="text/css">
/* style for title bar */
#title {
background: #C5D6D6;
color: black;
font-family: Verdana;
font-size: 1.5em;
font-weight: bold;
padding: 5px;
border-bottom: 1px solid black
text-align: center;
}
</style>
}
/// This XML block defines the contents of this page.
XData Contents [ XMLNamespace = "http://www.intersystems.com/
{
<page xmlns="http://www.
<html id="title">Demo: Dynamic Dyna Grid</html>
<spacer height="10"/>
<vgroup width="100%">
<dynaGrid id="dgDynaGrid" OnCr
showColumnLabels="true"
showRowLabels="false"
showZebra="true"
width="100%">
</dynaGrid>
</vgroup>
<!-- gridRow style="text-
<!-- onrender="zenPage.
</page>
}
ClassMethod CreateDS(pGrid As
{
Set $ZT="Error"
Kill ^UT("Demo.DynaGrid","
// Clear out data set
Do pDataSet.%Clear()
// column labels (dimension 2)
Set tHeader=^Demo.Import("
Set colWidths=""
For p=1:1:$LL(tHeader) {
Set colName=$TR($LG(tHeader,p)
Do pDataSet.%SetLabel(colName,
If colName="Employee" {
Set colWidths=colWidths_$Get(^
}
Set colWidths=colWidths_$Get(^
}
Do pDataSet.%SetLabel("
Set colWidths=colWidths_$Get(^
// get size of dataSet
//Set rows = pDataSet.%GetDimSize(1)
Set cols = pDataSet.%GetDimSize(2)
// Now populate the data in the new table
// Do pDataSet.%SetValue(value,row,
For row=2:1 {
If '$Data(^Demo.Import("
Set rowData=^Demo.Import("
For col=1:1:$LL(tHeader) {
}
Do pDataSet.%SetValue("Yes",(r
}
//
Set %page.columnWidths = colWidths
Set ^UT("Demo.DynaGrid","
Set ^UT("Demo.DynaGrid","
Set ^UT("Demo.DynaGrid","
//Do zenPage.setColumnWidths(pGrid, colWidths)
//
Quit $$$OK
Error //
Set ^UT("Demo.DynaGrid","
Do ^%ETN
}
ClientMethod dgRender(pGrid) [ Language = javascript ]
{
var colWidths=zenPage.
alert('dgRender:\n\n colWidths = ',colWidths);
pGrid.columnWidth = colWidths;
}
ClientMethod setColumnWidths(p
{
alert('setColumnWidths:\n\n colWidths = ',colWidths);
}
ClassMethod getColumnWidths() As %String
{
Set ^UT("Demo.DynaGrid","
Quit %page.columnWidths
}
}
Here is the data:
^Demo.Configuration("
^Demo.Configuration("
^Demo.Configuration("
^Demo.Configuration("
^Demo.Configuration("
^Demo.Configuration("
^Demo.Configuration("
^Demo.Configuration("
^Demo.Configuration("
^Demo.Configuration("
^Demo.Import("ImportedData",1)
^Demo.Import("ImportedData",2)
^Demo.Import("ImportedData",3)
^Demo.Import("ImportedData",4)
^Demo.Import("ImportedData",5)
^Demo.Import("ImportedData",6)
^Demo.Import("ImportedData",7)
^Demo.Import("ImportedData",8)
^Demo.Import("ImportedData",9)
^Demo.Import("ImportedData",
Thank you
Comments
Also, is it possible to add a dropbox in the cells in the CoConsultant column to allow user to choose a CoConsultant. The data will be retrieved from a table. And the 'Include' column is to indicate whether the user wants to include the row of data in the data that will be placed in the table. In the documentation I saw a reference to selected row which used a checkbox fair;ly far down on this page; https://docs.intersystems.com/ens201817/csp/docbook/Doc.View.cls?KEY=GZ…. It had a picture of a data grid with checkboxes in the second column.
Thank you.
For now I am skipping trying to get the column widths from the zen page property, columnWidths. I am hard coding the values in the dgRender method. I am using the below to change the column widths but the alerts are showing me that the first 3 columns are set but then dgRender (which is the target of the onrender property of the dynaGrid) is being called again. Not sure why this is happening.
ClientMethod dgRender(pGrid) [ Language = javascript ]
{
var colWidths = [300,110,110,200,160,60,300,100,50,60];
var dataSet = pGrid.getDataSet();
var maxrows = dataSet.getDimSize(1);
var maxcols = dataSet.getDimSize(2);
alert('dgRender:\n\n colWidths = ',colWidths);
for (var col=0; col<maxcols; col++) {
alert('dgRender:\n\n col = '+col+'\n colWidth = '+colWidths[col]);
pGrid.setColumnProperty(col, "columnWidth", colWidths[col]);
}
}
Thank you for your time.