Monday, February 16, 2015

Disabling Fields on a Page - The Simple Way

I couldn't find an easy code example of how to disable fields on a page, so this article shows one.  Rowsets, rows, and records do NOT have an Enabled property.  So the trick is to iterate through the fields in each record and set the Enabled property for those fields. And what's cool is you don't have to know the names of the fields to make this work.


For Level 0, there is only 1 row, so the code is a bit simpler:

   Local Row &rowLevel0 = GetLevel0()(1);
   Local Record &recLevel0 = &rowLevel0 .GetRecord(Record.MY_LEVEL_0_REC);
   For &numFields = 1 To &recLevel0.FieldCount
      &recLevel0 .GetField(&numFields).Enabled = False;
   End-For;

For subsequent levels in your component buffer, you'll need to iterate through the rowset's rows, but it's pretty straightforward as well.

   Local Rowset &rsLevel1 = GetLevel0()(1).GetRowset(Scroll.MY_LEVEL_1_REC);
   For &numRows = 1 To &rsLevel1.ActiveRowCount
      &rowLevel1 = &rsLevel1.GetRow(&numRows);
      &recLevel1 = &rowLevel1.getRecord(Record.MY_LEVEL_1_REC);
      For &numFields = 1 To &recLevel1.FieldCount
         &recLevel1.GetField(&numFields).enabled = False;
      End-For;
   End-For;

No comments: