EditTables - Getting multi-select data the easy way
Published 14 SEP 2022 at 12:54:05PM
In previous versions of OpenInsight the usual way of accessing data from a multi-row select EditTable control was to get the SELPOS property and then iterate over the data pulling out the rows, e.g. something like this (not optimized, but you get the idea):
SelPos = Get_Property( CtrlEntID, "SELPOS" ) DataList = Get_Property( CtrlEntID, "LIST" ) SelList = "" SelRows = SelPos<2> SelCount = FieldCount( SelRows, @Vm ) For SelIdx = 1 To SelCount SelRow = SelRows<0,SelIdx> SelList<-1> = DataList Next
However, in OpenInsight 10 we added a couple of new properties that allow you to access data in a multi-row select EditTable in a faster and more efficient way. These are:
- The SELLIST property
- The SELARRAY property
Both of these return data in the familiar LIST and ARRAY formats, but they only return data from the selected rows, thereby saving you the step of accessing SELPOS and iterating over the data yourself. So, to rewrite the example above we can now do this:
SelList = Get_Property( CtrlEntID, "SELLIST" )
Likewise, to return the data in ARRAY format we would use the SELARRAY property like so:
SelArray = Get_Property( CtrlEntID, "SELARRAY" )
Ergo, when asked the other day "What's the fastest way of getting data from a specific column from the selected rows", the answer was:
SelData = Get_Property( CtrlEntID, "SELARRAY" )
(And this question is also what led me to write this post…)
Bonus Trivia
The LISTBOX control also supports the SELLIST property.