show different item on selectionchange on a grid

纵饮孤独 提交于 2019-12-18 09:18:09

问题


i have a grid and a form, i need to show different items on the form each time we select a row on that grid

i ve been looking on how to do this, and found

    Ext.getCmp('myform').hide() // or  .show()

and

    listeners: { selectionchange: function () {...}

now i dont know which row is selected so i can specify which item to show

thanks


回答1:


Try to following code in your grid.

        listeners:{
                itemclick:function(view, record, item, index, e ) {
                var v = record.get('firstName');
                ....
                    ....
                     }
                  }

firstName will be your dataindex of colums in your grid. You can get value of any field like this.




回答2:


You get the selected rows as second parameter in the selectionchange event handler:

listeners: {
    selectionchange: function (view, selections, options) {
        console.log(view, selections, options);
    }
}

So the first selected row is the first element in the selections array:

record = selections[0]

This is described in the Ext JS 4 API documentation for the selectionchange event.



来源:https://stackoverflow.com/questions/6453312/show-different-item-on-selectionchange-on-a-grid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!