0

After upgrading to the Aviarc 3.6.0 we are getting the mentioned error on one of the screens.

The part of the screen which raises an error:

<custom:record-table bottom="40" width="100%" left="0" top="0" dataset="account-ds" class="list" name="accountlist-rc" >
    <column width="0" display-field="AccountName"  header="Accounts" field2="AccountCode"  allow-sort="n" />
</custom:record-table>

Note that we customized the record-table widget to allow for 2 additional fields to be specified for each column (field2 and field3), so this is where field2 in the column comes from.

Vlad
  • 385
  • 3
  • 10
  • What are the field2 and field3 used for? – Tristan Wilkinson Sep 24 '12 at 02:54
  • @TristanWilkinson Both **field2** and **field3** in this widget used to provide additional fields for the column. As an example on that screen the entry in the column taken from **display-field** would have large font, while entry from the **field2** would be on the new line with smaller font. **field3** when used concatenates the content of **display-field** and/or **field2** values with the value coming from **field3** field. – Vlad Sep 24 '12 at 05:36

1 Answers1

1

After investigating the changes done to allow for more than 1 field to be specified for each column of the record table were looking as follows (in the update method of the RecordTable.js, starting from line 670):

var field = this._datasetRow.getFieldObject(column.attributes['display-field']);
var field2 = this._datasetRow.getFieldObject(column.attributes['field2']);
var field3 = this._datasetRow.getFieldObject(column.attributes['field3']);

var text = field.getValue();
var text2 = field2.getValue();
var text3 = field3.getValue();

Since the column specification on the screen (code snippet in the question) does not set any value to field3 attribute the part

var field3 = this._datasetRow.getFieldObject(column.attributes['field3']);

was failing and throwing an error. Method getFieldObject always expects the value to be passed, even though it should probably be smart enough to cater for null/undefined values as well.

To solve the problem the code was refactored as follows:

var field = this._datasetRow.getFieldObject(column.attributes['display-field']);
var text = field.getValue();
if (column.attributes['field2'] != null) {
    var field2 = this._datasetRow.getFieldObject(column.attributes['field2']);
    var text2 = field2.getValue(); 
}
if (column.attributes['field3'] != null) {
    var field3 = this._datasetRow.getFieldObject(column.attributes['field3']);
    var text3 = field3.getValue();
}

After that the custom part of the widget code simply needs to cater for possible undefined values of text2 and text3 attributes.

Vlad
  • 385
  • 3
  • 10