Sencha Touch以编程方式选择或突出显示嵌套列表项

时间:2011-06-09 05:14:09

标签: list select nested sencha-touch

我尝试使用以下代码选择/突出显示嵌套列表项:

var activelist= nestedList.getActiveItem();
var listselectednode = activelist.getNode(1);
nestedPanel.fireEvent('itemtap',activelist,1,listselectednode ,e);

但不行。

帮助

1 个答案:

答案 0 :(得分:0)

为了后人,这里是你如何选择(突出显示)一个节点。这个答案改编自对这个问题的评论。

var activeList = nestedList.getActiveItem();

// By index<br/>
activeList.getSelectionModel().select(index)

// By ID<br/>
var targetNode = activeList.store.getById(id);
activeList.getSelectionModel().select(targetNode);


以下是您选择和点击节点的方式(按ID)。

var activeList = nestedList.getActiveItem();
var targetNode = activeList.getNode(activeList.store.getById(targetNodeId));
var e = {} // You can provide event data here, if you like.

if (targetNode) {
  var targetIndex = activeList.indexOf(targetNode);

  nestedList.fireEvent('itemtap', activeList, targetIndex, targetNode , e);
  activeList.getSelectionModel().select(targetIndex, true);
}