开发者

Sencha Touch select or highlight an item of nestedlist programally

I try to select/highlight an item of nestedlist with this code:

var activelist= nestedList.getActiveItem();
var listselectednode = activelist.getNode开发者_JAVA百科(1);
nestedPanel.fireEvent('itemtap',activelist,1,listselectednode ,e);

but not work.

Help


For posterity's sake here is how you just select (highlight) a node. This answer was adapted from the comments on the question.

var activeList = nestedList.getActiveItem();

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

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


And here is how you select and tap a node (by 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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜