_ArrayView_Header_Run (Generic List Setup)

came across the Genric List cicode example (below) which uses the arrays functions to populate the generic lists which part of the sa_controls library. is anyone able to provide more info on where the _ArrayView functions are located? doesn't seem to appear in any of the include functions etc.

FUNCTION Test_GenericListFill(INT hAn)
   INT nRow = 0;
   INT nRows = 10;
   INT nColumn = 0;
   INT nColumns = 5;
   INT nOffset = 0;
   INT nOffset_Previous = 0;
   INT nDataColumns = 0;
   INT nDataRows = 0;
   INT hDataArray = -1;
   STRING sMapName = "";
   STRING sValue = "";

   IF (ArrayExistsByAn(hAn)) THEN
      _ArrayView_Header_Run(hAn);
      _ArrayView_VScroll_Run(hAn);
      _ArrayView_HScroll_Run(hAn);

      sMapName = ArrayGetMapNameByAn(hAn);
      hDataArray = MapValueGet(sMapName, "DataArray");
      nOffset_Previous = MapValueGet(sMapName, "Offset");
      nOffset = ArrayGetIntByAn(hAn, ARRAY_INFORMATION_COLUMN, ARRAY_INFORMATION_ROW, ARRAY_ZINDEX_ARRAY_YOFF);

      hDataArray = MapValueGet(sMapName, "DataArray");
      IF ((ArrayIsDirty(hDataArray)) OR (nOffset <> nOffset_Previous)) THEN
         nDataColumns = MapValueGet(sMapName, "DataColumns");
         nDataRows = MapValueGet(sMapName, "DataRows");

         FOR nRow = 1 TO nRows DO
            FOR nColumn = 1 TO nColumns DO
               sValue = ArrayGetString(hDataArray, nColumn - 1, (nOffset + nRow) - 1, 0);
               ArraySetStringByAn(hAn, sValue, nColumn, nRow, ARRAY_ZINDEX_CELL_VALUE);
            END
         END

         MapValueSet(sMapName, "Offset", nOffset);
         ArraySetIsDirty(hDataArray, FALSE);
      END
   END
END
  • Hi Ignatius,

    All the functions are located in: [SA_Controls]\Arrayview.ci

    It looks like we may have updated the library and didn't apply the changes to the example.

    _ArrayView_Header_Run is actually ArrayView_Header_Run (no leading underscore).

    Technically our examples shouldn't be using/calling internal functions (functions with leading underscores)... I'll have to get the team to look at that some time.

    cheers,

    bradley
  • Thanks. yes it now works. however the list has a LeftClickCommand function. how can i retrieve what was selected? is this by a string value or index in the array? the example mentioned a right click command which would show a context menu. do you have examples of how to implement both commands?
  • Not on me at the moment. Just off the top of my head, I'd probably do it like this:

    For full row select, make sure you have a list row genie (list_row_x10/x40) behind your list genie. That genie has full row click handlers on it. (See the TrendPage in your start project)

    In the genie properties of the list_row_x10/x40 genie you should see "Left Click Command". Enter a name of a function that has the following signature:

    MyList_LeftClick(INT hArrayAn, INT nRowOffset, INT nRow)

    To implement the function have a look at:

    "_AlarmList_Row_LeftClick" in [SA_Controls]AlarmList.ci

    If you get stuck, I'll see If I can find some time to do a up quick handler.

    cheers,

    bradley
  • the _AlarmList_Row_LeftClick function is the default function in the list_row_x10 genie.
    using the example code provided by Citect titled [Situational Awareness Projects > Customize a Project > Add a Generic List to a Page]. the list entry does not get highlighted when the left mouse button is invoked on the generic list entry.
    however in the default alarm page in (examplesa) leftclicking on the alarmlist highlights the entire row (its also using the same list_row_x10 genie)

    the main problem seems to be the sRecID = ArrayGetStringByAn(hArrayAn, ARRAY_INFORMATION_COLUMN,nRowOffset+nRow, ARRAY_ZINDEX_ROW_ID) is returning "" when the Generic list code example is used.

    with the alarmlist, the RecId is returned.
    seems like an issue with the initalisation of the generic array in the first place

    any advise?
  • Hmm, I think we have an oversight on our behalf here. the list_row_x genies were meant to work with alarm lists or generic lists. The hardcode of the alarm func, I don't believe was intentional.

    I'll have to get the team to look at this and correct. 

    Anyway, hopefully it your scenario having the list_row_x10 genies calling the alarmlist_row_leftclick will be harmless.

    I did up a quick example project,and this is my handler:

    FUNCTION SimpleList_OnLeftClick(INT hArrayAn)
     INT iSelectedRow = StrToInt(_ArrayView_Selected_RecID(hArrayAn));
     Message("Citect", "You clicked on Row: " + iSelectedRow:# + ", 0);
    END
  • correct, that will return the row number selected in the genie. in the alarm list version, the row number is then used with the offset to enable AlarmGetDsp to get to the Alarm to setup a map with the alarm details . in a generic list setup, the Map doesn't exist upon invoke _AlarmList_Row_LeftClick. can we still get the object value from the selected row.
    also the genericlist genies include a vertical scroll bar. When testing the selection, when the list is scrolled the iSelectedRow does not seem to be unique across the scroll pages. example, select row 2, then scroll to go to next page and both iSelectedRows are still no 2. i would have expected a unique value so that i may be easy to retrieve the An of the row entry?
  • I will check the vertical genie. I used the std generic list and iSelectedRow is unique. Unless you are displaying genies in the rows, instead of text, then I see no reason to get access to the AN's as you can use the unique index to go straight into your data model. We have a special technique for getting access to the graphical elements of the view rows if genies are used. See "TrendPage_FillEquipmentItemList" for that technique. Basically every cell has a meta data field, which you can pass a string to allowing the metadata of objects in the genie to be set.
  • i had a look at the trendpage_fillequipmentitemlist but it sets the controls from within the array itself and not returning the value of what's selected. what i'm after is the value (not record id) of the selected record when i left_click on the list. do we have a working example somewhere? Thanks