grid 表头标题栏添加点击事件

grid 表头标题栏添加点击事件,第1张

grid 表头标题栏添加点击事件的方法如下:

在<mx:DataGrid headerRelease="doHeaderRelease(event)"/>调用下面方法获取所在列以及dataField和headerText

在用datagrid的时候我们可能要用到点击表头来触发一个function,这里有个简单的例子。

首先你得有个能用的datagrid。

<div>

<table id="toolbar"></table>

</div>

然后是js里的东西。

function toolbar(){

alert("dd")

$("#toolbar").datagrid({

striped: true,

url:"toolbar",

columns:[[

{field:"name",title:click()},

{field:"sex", title:"性别"},

{field:"age", title:"年龄"},

]],

toolbar:[{

text:'增加',iconCls:'icon-add',handler:function(){

alert(document.getElementById("text").value)}

},

{text:'导入',iconCls:'icon-add',handler:function(){

window.location.href='StuImport.aspx'

很简单;不用修改html页面

js如下

window.onload=init;

function init(){

var trs=documents.getElmentsByTagName('TR')

for(var i=0i<trs.lengthi++)

trs[i].onclick=doclick

}

function doclick(){

alert(this.innerHTML)

}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11867153.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-19
下一篇2023-05-19

发表评论

登录后才能评论

评论列表(0条)

    保存