ExtJS4获取控件展示的信息---获取grid选中项信息
2014-06-18 12:38
471 查看
一、表格grid获取选中行的数据信息:
添加listensers监听器,监听函数可以获取表格信息:
1.选中一行的时候:
2.在双击的时候:
表格中添加一个列,点击时获取行的信息或者执行其他相关当前行的操作:
在某个button按钮获取其他情况下获取选中的行:
可以使用这种方法实现:
也可以这样子取值:
通过getLastSelected()方法获取该行Model格式的数据,然后get需要的值。
二、在其他地方(比如某个button事件)获取某个控件选中的值或者数据
1.radiogroup中获取选中值:
在某个地方,可以这样获取选中的radio元素值:
2.获取日期控件的日期值:
如果需要对获取的日期格式化处理,则可以:
添加listensers监听器,监听函数可以获取表格信息:
1.选中一行的时候:
selectionchange: function(model, records) { if (records[0]) { alert(records[0].data.company);//alert出选中行的company字段内容 this.up('form').getForm().loadRecord(records[0]);//将选中行的内容载入到form表单 } }
2.在双击的时候:
itemdblclick:function(view, record, items, index, e){ // this.up('form').getForm().loadRecord(record); alert(record.data.ID_CARD_NUMBER);//record为当前双击的行,alert出ID_CARD_NUMBER字段内容 }
表格中添加一个列,点击时获取行的信息或者执行其他相关当前行的操作:
{ header : '维挽', xtype : 'actioncolumn', width : 50, sortable : false, items : [{ icon : 'image/icons/delete.gif', tooltip : '删除已经维系挽留的用户',
handler : function(grid, rowIndex, colIndex) { Ext.Ajax.request({ url : 'deleteIsHold?name='+ store.getAt(rowIndex).data 4000 .ACCOUNT_USER, success : function(response, options) {store.removeAt(rowIndex);}, failure : function(response, options) {Ext.Msg.alert('成功',Ext.decode(response.responseText).msg);} }); } }] }
在某个button按钮获取其他情况下获取选中的行:
handler: function(btn, pressed) { var row=Ext.getCmp("id_journal_grid").getSelectionModel().getSelections(); //选择行的个数 ,但是本人ExtJS4上面测试出现错误,提示getSelections()不是函数, if(row.length==0) { Ext.Msg.alert("提示信息","请您至少选择一个!"); } else if(row.length>1){ Ext.Msg.alert("提示信息","对不起只能选择一个!"); }else if(row.length==1) { EditJournalInfo(row[0]);//传行一行记录直接加载 编辑角色信息 } },//上面的方式估计是ExtJS以前的版本?
可以使用这种方法实现:
var row=Ext.getCmp("gridpanel").getSelectionModel().getLastSelected();//选择行的个数可以这样取值:
alert(row.get('ID_CARD_NUMBER'));
也可以这样子取值:
alert(row.data.ID_CARD_NUMBER);
通过getLastSelected()方法获取该行Model格式的数据,然后get需要的值。
二、在其他地方(比如某个button事件)获取某个控件选中的值或者数据
1.radiogroup中获取选中值:
{//某个地方定义的一个radiogroup xtype : 'radiogroup', id:'group2', fieldLabel : '?????', labelWidth:200, defaultType : 'radiofield', defaults : { flex : 1 }, layout : 'hbox', items : [{ boxLabel : '是', name : 'isNew', inputValue : 'yes', id : 'radio3' }, { boxLabel : '否', name : 'isNew', inputValue : 'no', id : 'radio4', checked:true, margin : '0 0 0 90' }] }
在某个地方,可以这样获取选中的radio元素值:
var radio2 = Ext.getCmp('group2').getChecked()[0].boxLabel;
2.获取日期控件的日期值:
Ext.getCmp('month').getValue();
如果需要对获取的日期格式化处理,则可以:
var mytime = Ext.util.Format.date(Ext.getCmp('month').getValue(), 'Y-m');
相关文章推荐
- DevExpress.XtraGrid.GridControl控件获取选中行某列的值
- 用树展示上下级关系-jquery+ztree+json的运用之获取选中的信息
- ExtJs 4 grid 批量删除 获取选中行ID
- bootstrop-table之通用方法( 时间控件,导出,动态下拉框, 表单验证 ,选中与获取信息)
- DEV控件:gridControl常用属性设置:获取选中行的值
- bootstrap table之通用方法( 时间控件,导出,动态下拉框, 表单验证 ,选中与获取信息)代码分享
- ExtJs——获取GridPanel中的行数据的详细信息
- Extjs获取GridPanel选中行的信息
- Coolite GridPanel 操作之一:获取gridpanel 选中行的记录信息
- 获取UltraWebGrid选中行的信息
- DevExpress.XtraGrid.GridControl控件获取选中行某列的值
- extjs 3.4 EditorGridPanel里日期控件在后台获取格式为"2015-10-10T00:00:00"的问题解决
- DEV控件:gridControl常用属性设置:获取选中行的值
- bootstrop-table之通用方法( 时间控件,导出,动态下拉框, 表单验证 ,选中与获取信息)
- extjs获取grid的选中数据
- Extjs Grid获取当前选中的行号
- 用树展示上下级关系-jquery+ztree+json的运用之获取选中的信息
- extjs grid columns 信息获取
- DEV控件:gridControl常用属性设置:获取选中行的值
- Coolite GridPanel 操作之一:获取gridpanel 选中行的记录信息