Build a simple Grid

Steps:

  1. Follow Build a Generic Report until the step to add report parts.
  2. Prepare an empty ReportPartGrid object with default properties.
  3. For each selected data source fields, populate a ReportPartElement object with default properties.
  4. Add the ReportPartElement objects into columns.elements in ReportPartGrid object.
  5. Update the properties of the grid in properties field per user selection (See ReportPartGridProperties).
  6. Back to the steps in Build a Generic Report.

Prepare an empty ReportPartGrid object

Empty ReportPartGrid object


  • The highlighted columns.elements is where the selected data source fields will be added
  • The highlighted properties contains the default properties
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{
   "type": 3,
   "columns": {
      "elements": [],
      "name": "columns"
   },
   "rows": {
      "elements": [],
      "name": "rows"
   },
   "values": {
      "elements": [],
      "name": "values"
   },
   "separators": {
      "elements": [],
      "name": "separators"
   },
   "properties": {
      "generalInfo": {
         "gridStyle": "Vertical",
         "separatorStyle": "Comma"
      },
      "table": {
         "border": {
            "top": {},
            "right": {},
            "bottom": {},
            "midVer": {},
            "left": {},
            "midHor": {}
         },
         "backgroundColor": "#fff"
      },
      "columns": {
         "width": {
            "value": 150
         },
         "alterBackgroundColor": false
      },
      "rows": {
         "alterBackgroundColor": false
      },
      "headers": {
         "font": {
            "family": "Roboto",
            "size": 14,
            "bold": true,
            "italic": false,
            "underline": false,
            "backgroundColor": "#E4E4E4"
         },
         "alignment": "left",
         "wordWrap": false,
         "removeHeaderForExport": false
      },
      "grouping": {
         "useSeparator": true
      },
      "view": {
         "dataRefreshInterval": {
            "enable": false,
            "updateInterval": 0,
            "isAll": true,
            "latestRecord": 0
         },
         "usePagination": true,
         "pivotColumnsPerExportedPage": "",
         "pageSize": 10
      },
      "printing": {
         "usePageBreakAfterSeparator": false
      }
   },
   "settings": {},
   "title": {
      "text": "",
      "properties": {},
      "settings": {
         "font": {
            "family": "",
            "size": 14,
            "bold": true,
            "italic": false,
            "underline": false,
            "color": "",
            "highlightColor": ""
         },
         "alignment": {
            "alignment": ""
         }
      },
      "elements": []
   },
   "description": {
            "text": "",
            "properties": {},
            "settings": {
               "font": {
                  "family": "",
                  "size": 14,
                  "bold": false,
                  "italic": false,
                  "underline": false,
                  "color": "",
                  "highlightColor": ""
               },
               "alignment": {
                  "alignment": ""
               }
            },
            "elements": []
   }
}

Populate selected data sources fields

  1. Get the list of available data sources fields from POST report/availableQuerySourceFields with this payload:

    {
       "reportKey": {
          "key": "<the id of the report>"
       }
    }
    

    The response is an array containing exactly one ReportDataSourceCategory object, with querySource field containing an array of selected data sources (ReportQuerySource objects), with fields field containing an array of available data source fields. For example:

    [
       {
          "id": null,
          "name": "Selected Data Source",
          "querySource": [
             {
                "id": "af773c7b-878e-461b-9345-27ee6592db1a",
                "name": "Orders",
                "originalName": "Orders",
                "type": "Table",
                "selected": true,
                "visible": true,
                "querySourceCategoryName": "dbo",
                "connectionName": "test",
                "isAlias": false,
                "isDynamic": false,
                "fields": [
                   {
                      "name": "CustomerID",
                      "remaining items": "have been omitted"
                   },
                   {
                      "name": "OrderID",
                      "remaining items": "have been omitted"
                   }
                ]
             }
          ]
       }
    ]
    
  2. For each selected data source field (QuerySourceField object), build a corresponding ReportPartElement object

    {
       "name": "<User-defined Field Name Alias of the selected QuerySourceField>",
       "position": "<position in the list of selected fields>",
       "field": {
          "fieldId": "<id of the selected QuerySourceField>",
          "fieldName": "<name of the selected QuerySourceField>",
          "fieldNameAlias": "User-defined Field Name Alias of the selected QuerySourceField",
          "dataFieldType": "<Izenda data type of the selected QuerySourceField>",
          "querySourceId": "<id of the parent QuerySource>",
          "querySourceType": "<Table, View or Stored Procedure>",
          "sourceAlias": "",
          "relationshipId": null,
          "visible": true,
          "calculatedTree": null,
          "schemaName": "<name of the schema>",
          "querySourceName": "<name of the parent QuerySource>",
          "databaseName": "<name of the connection>",
          "isCalculated": false,
          "hasAggregatedFunction": false
       },
       "properties": {}
    }
    
    Sample QuerySourceField Sample ReportPartElement
    {
       "name": "OrderID",
    
    {
       "name": "OrderID",
    
     
       "position": 1,
    
       "id": "b648344c-526e-4984-bfc3-7be462b800fe",
    
          "fieldId": "b648344c-526e-4984-bfc3-7be462b800fe",
    
       "name": "OrderID",
    
          "fieldName": "OrderID",
    
    User entered “OID”
          "fieldNameAlias": "OID",
    
       "izendaDataType": "Numeric",
    
          "dataFieldType": "Numeric",
    
       "querySourceId": "af773c7b-878e-461b-9345-27ee6592db1a",
    
          "querySourceId": "af773c7b-878e-461b-9345-27ee6592db1a",
    
       "type": 0,
    
          "querySourceType": "Table",
    
    Alias of the parent QuerySource
          "sourceAlias": "Orders",
    
    Name of the schema
          "schemaName": "dbo",
    
    Name of the parent QuerySource
          "querySourceName": "Orders",
    
    Name of the database
          "databaseName": "test",
    
       "visible": true,
    
          "visible": true,
    
     
          "relationshipId": null,
          "calculatedTree": null,
          "isCalculated": false,
          "hasAggregatedFunction": false
       },
    

    See Sample Properties for a ReportPartElement for more samples.

  3. Populate a default ReportPartElementProperties for properties field in each ReportPartElement object

    Default ReportPartElementProperties object

    {
       "fieldItemVisible": true,
       "dataFormattings": {
          "function": "",
          "functionInfo": {},
          "format": {},
          "font": {
             "family": "Roboto",
             "size": 14,
             "bold": false,
             "italic": false,
             "underline": false,
             "color": "",
             "backgroundColor": ""
          },
          "width": {
             "value": null
          },
          "alignment": "alignLeft",
          "sort": "ASC",
          "color": {
             "textColor": {
                "rangePercent": null,
                "rangeValue": null,
                "value": null
             },
             "cellColor": {
                "rangePercent": null,
                "rangeValue": null,
                "value": null
             }
          },
          "alternativeText": {
             "rangePercent": null,
             "rangeValue": null,
             "value": null
          },
          "customURL": {
             "url": "",
             "option": "LINK_NEW_WINDOW"
          },
          "embeddedJavascript": {
             "script": ""
          },
          "subTotal": {
             "label": "",
             "function": "",
             "expression": "",
             "dataType": "",
             "format": {},
             "previewResult": ""
          },
          "grandTotal": {
             "label": "",
             "function": "",
             "expression": "",
             "dataType": "",
             "format": {},
             "previewResult": ""
          }
       },
       "headerFormating": {
          "font": {
             "family": null,
             "size": null,
             "bold": null,
             "italic": null,
             "underline": null,
             "color": null,
             "backgroundColor": null
          },
          "alignment": null,
          "wordWrap": null,
          "columnGroup": ""
       },
       "drillDown": {
          "subReport": {
             "selectedReport": null,
             "style": null,
             "reportPartUsed": null,
             "reportFilter": true,
             "mappingFields": [],
             "selectedIconValue": {
                "icon": null,
                "value": null
             },
             "viewSettingByLink": null
          }
       },
       "otherProps": {}
    }
    
  4. Add the ReportPartElement objects into columns.elements in ReportPartGrid object.

    Sample full ReportPartGrid object

    {
       "type": 3,
       "columns": {
          "elements": [
             {
                "name": "OrderID",
                "position": 1,
                "field": {
                   "fieldId": "b648344c-526e-4984-bfc3-7be462b800fe",
                   "fieldName": "OrderID",
                   "fieldNameAlias": "OID",
                   "dataFieldType": "Numeric",
                   "querySourceId": "af773c7b-878e-461b-9345-27ee6592db1a",
                   "querySourceType": "Table",
                   "sourceAlias": "Orders",
                   "schemaName": "dbo",
                   "querySourceName": "Orders",
                   "databaseName": "test",
                   "visible": true,
                   "relationshipId": null,
                   "calculatedTree": null,
                   "isCalculated": false,
                   "hasAggregatedFunction": false
                },
                "properties": {
                   "fieldItemVisible": true,
                   "dataFormattings": {
                      "function": "",
                      "functionInfo": {},
                      "format": {},
                      "font": {
                         "family": "Roboto",
                         "size": 14,
                         "bold": false,
                         "italic": false,
                         "underline": false,
                         "color": "",
                         "backgroundColor": ""
                      },
                      "width": {
                         "value": null
                      },
                      "alignment": "alignLeft",
                      "sort": "ASC",
                      "color": {
                         "textColor": {
                            "rangePercent": null,
                            "rangeValue": null,
                            "value": null
                         },
                         "cellColor": {
                            "rangePercent": null,
                            "rangeValue": null,
                            "value": null
                         }
                      },
                      "alternativeText": {
                         "rangePercent": null,
                         "rangeValue": null,
                         "value": null
                      },
                      "customURL": {
                         "url": "",
                         "option": "LINK_NEW_WINDOW"
                      },
                      "embeddedJavascript": {
                         "script": ""
                      },
                      "subTotal": {
                         "label": "",
                         "function": "",
                         "expression": "",
                         "dataType": "",
                         "format": {},
                         "previewResult": ""
                      },
                      "grandTotal": {
                         "label": "",
                         "function": "",
                         "expression": "",
                         "dataType": "",
                         "format": {},
                         "previewResult": ""
                      }
                   },
                   "headerFormating": {
                      "font": {
                         "family": null,
                         "size": null,
                         "bold": null,
                         "italic": null,
                         "underline": null,
                         "color": null,
                         "backgroundColor": null
                      },
                      "alignment": null,
                      "wordWrap": null,
                      "columnGroup": ""
                   },
                   "drillDown": {
                      "subReport": {
                         "selectedReport": null,
                         "style": null,
                         "reportPartUsed": null,
                         "reportFilter": true,
                         "mappingFields": [],
                         "selectedIconValue": {
                            "icon": null,
                            "value": null
                         },
                         "viewSettingByLink": null
                      }
                   },
                   "otherProps": {}
                },
                "isDeleted": false,
                "isSelected": false,
                "offset": {}
             }
          ],
          "name": "columns"
       },
       "rows": {
          "elements": [],
          "name": "rows"
       },
       "values": {
          "elements": [],
          "name": "values"
       },
       "separators": {
          "elements": [],
          "name": "separators"
       },
       "properties": {
          "generalInfo": {
             "gridStyle": "Vertical",
             "separatorStyle": "Comma"
          },
          "table": {
             "border": {
                "top": {},
                "right": {},
                "bottom": {},
                "midVer": {},
                "left": {},
                "midHor": {}
             },
             "backgroundColor": "#fff"
          },
          "columns": {
             "width": {
                "value": 150
             },
             "alterBackgroundColor": false
          },
          "rows": {
             "alterBackgroundColor": false
          },
          "headers": {
             "font": {
                "family": "Roboto",
                "size": 14,
                "bold": true,
                "italic": false,
                "underline": false,
                "backgroundColor": "#E4E4E4"
             },
             "alignment": "left",
             "wordWrap": false,
             "removeHeaderForExport": false
          },
          "grouping": {
             "useSeparator": true
          },
          "view": {
             "dataRefreshInterval": {
                "enable": false,
                "updateInterval": 0,
                "isAll": true,
                "latestRecord": 0
             },
             "usePagination": true,
             "pivotColumnsPerExportedPage": "",
             "pageSize": 10
          },
          "printing": {
             "usePageBreakAfterSeparator": false
          }
       },
       "settings": {},
       "title": {
          "text": "",
          "properties": {},
          "settings": {
             "font": {
                "family": "",
                "size": 14,
                "bold": true,
                "italic": false,
                "underline": false,
                "color": "",
                "highlightColor": ""
             },
             "alignment": {
                "alignment": ""
             }
          },
          "elements": []
       },
       "description": {
          "text": "",
          "properties": {},
          "settings": {
             "font": {
                "family": "",
                "size": 14,
                "bold": false,
                "italic": false,
                "underline": false,
                "color": "",
                "highlightColor": ""
             },
             "alignment": {
                "alignment": ""
             }
          },
          "elements": []
       }
    }
    

Update the properties of each field per user selection

Please see ReportPartElementProperties for the purpose of each field.

See Sample Properties for a ReportPartElement for more samples.

Update the properties of the grid in “properties” field per user selection

Please see ReportPartGridProperties for the purpose of each field.

Back to the step in Build a Generic Report