Skip to Content
avatar image
Former Member

Selection in table with Master Column

Hi,

can anybody explain me how selection works in table with MasterColumn (TreeByNestingTableColumn)?

I've created a table with several columns and the "master" one behaves differently from others.

First of all, leaf elements of master column are not clickable (i.e. I don't receive notification "onLeadSelect" from the table, when user clicks in the cell of leaf element of the column). With expandable elements I receive loadchildren event and can react on selection.

I'm using TextView as cell editor, will try LinkToAction, may be it will resolve situation, but it's rather workaround as solution

Second, getLeadSelection doesn't work anymore for the table - it works with indexes of top level elements only.

However onLeadSelect action brings me selected row number, which I somehow should map to the tree.

I.e. when I get "25" as selected element, I recursively traverse context node to find 25th element. Which is rather slow operation as for any selection I have to reiterate whole structure and I hope that visual appearance is similar to context element order.

May be there is simplier ways to get selected element by its index in "flat" list?

And one another strange thing: first click on the table sends me onLeadSelect "0", but highlight points to the element user clicked - not necessary first one.

Context node is "single" selection, initLeadSelect=true,

selection = 0..1 (with 1..1 setTreeSelection doesn't work - method I want to use to be able to select a node in hierarchy on my own)

all quite similar to other tables I have, which works well. Just the problems with the table, where Master Column is used.

Thank you!

Best regards,

Nick

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Apr 26, 2005 at 06:17 PM

    FYI: replaced TextView by LinkToAction as cell editor for Master Column. No reaction at all on clicking the underlined text. onAction event is not called 😔

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      >Valery's proposal was to perform reverse traverse from current element to root and summarize parent element indexes.

      It seems to work:

      in method, which sets selection I applied

      ...

      // we need to know index of the element not in whole context, but in scope of table-relevant node

      int index = getIndexInContext(selElement, wdContext.currentXXXElement());

      IContextElement curContext = wdContext.currentContextElement();

      int firstVisibleRow = curContext.getTableFirstVisibleRow();

      int visibleRows = curContext.getTableVisibleRows();

      if (index < firstVisibleRow || index > firstVisibleRow + visibleRows) {

      curContext.setTableFirstVisibleRow(index);

      }

      ...

      and method getIndexInContext looks as:

      private int getIndexInContext (IWDNodeElement element, IWDNodeElement root) {

      int index = element.index();

      if (element == root) {

      return index;

      }

      IWDNodeElement parent = element.node().getParentElement();

      if (parent == null) {

      // do whatever you like here for error diagnostic

      myMsgMgr.reportException("Internal Error: getIndexInContext - element is not under passed root", false);

      return 0;

      }

      // +1 - every level adds 1 (otherwise indexes of first children of hierarchy will be 0)

      return index + getIndexInContext(parent, root) + 1;

      }

      Best regards,

      Nick