0

I have a data table and I want to show detail when clicking each row on it. But the index always returns 0.

int index= wdContext.getCurrentElement().index();
wdComponentAPI.getMessageManager().reportSuccess("test "+ index);

enter image description here

Please help me review and give your thoughts.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Phạm Quốc Bảo
  • 864
  • 2
  • 10
  • 19

1 Answers1

0

You have several options here. First option:

wdContext.node<YourNode>.getLeadSelection().index();

Pay attention to get lead selection of your node but not of the root context. Also context mapping should be properly defined for this to work.

Second option is to use wdDoModifyView event:

wdDoModifyView(...)
{
if (firstTime)
 {
  IWDLinkToAction link = (IWDLinkToAction) view.getElement("LinkID");
  link.mappingOfOnAction().addSourceMapping("nodeElement", "rowElement");
 }
}

Here we map built-in parameter nodeElement to our target rowElemen parameter which would be used in LinkToAction handler.

void onActionLinkClicked(..., I<DataSourceNode>Element rowElement)
{
 /* do whatever with row element */
}
Suncatcher
  • 10,355
  • 10
  • 52
  • 90