CAF.Model returns null for controls in an async table

Hi,

I need help.

I have an async table with the ID:asyncTable. I registered an event listener for the table so that when the row changes, I would like to prompt for the selected row’s first column’s value.

Here is how I am registering my event listener:

var tableModel = CAF.model(‘#{caf:cid(“defaultForm:asyncTable”)}’);
tableModel.addRowChangeListener(function(tableId, rowId, eventType) {
if (tableModel.getRowSelectedCount() > 0)
{
alert(“There is a selected row!”);
}
});

So far, the above code works. Before proceeding, I note the first column’s text control’s ID, which is “listRowColumn”. Hence, I update the above script to the following

var tableModel = CAF.model(‘#{caf:cid(“defaultForm:asyncTable”)}’);
tableModel.addRowChangeListener(function(tableId, rowId, eventType) {
if (tableModel.getRowSelectedCount() > 0)
{
var row = CAF.model(rowId);
var nameId = row.getControlId(“listRowColumn”);
alert(nameId);
alert(CAF.model(nameId).getValue());
}
});

What happens now is I get the first alert, which gives me the value for “nameId”. However, the second alert never shows up. Looking at the error console on my browser, it says “CAF.model(nameId) is null”, which is weird. Does this mean I cannot get values from the column?

Thanks in advance!

Check the text control in your column to make sure the ‘Raw’ property is not set to true. When a text control is configured to be raw, it can not be retrieved by its id in the client side model because there is no wrapping span html tag around the text.

For example:

<span id='control_id_here'>text here</span>

The raw text control is the default as a performance optimization since it is not common to need to reference that text by id in the browser. If you need access to that text control from script, you would need to mark the text control as not raw.

That’s BRILLIANT! Issue is resolved. Thanks Eric!