javascript – 如何在jqgrid中的行上自定义按钮添加脚本?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了javascript – 如何在jqgrid中的行上自定义按钮添加脚本?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2618字,纯文字阅读大概需要4分钟。
内容图文
![javascript – 如何在jqgrid中的行上自定义按钮添加脚本?](/upload/InfoBanner/zyjiaocheng/798/45d5f471b9c44cdb84e27bab13389be6.jpg)
我试图处理jqgrid中的自定义按钮的单击.我有按钮显示,但单击它们时,我的功能不会运行.如果我单击jqgrid外部的按钮,脚本将运行. jqgrid是否消耗了按钮点击?不确定我缺少什么或不理解.这是网格.我没有重新加载整个网格的原因是服务器上有太多的处理,并且一旦editurl处理“发送”,需要手动删除客户端上的行.请参阅:$(“.sendbuttons”).click(function(){
…
<style type="text/css">
.sendbuttons {
height:19px;
width:60px;
color:red;
}
</style>
<script language="javascript">
jQuery(document).ready(function(){
var last_row;
jQuery("#gridlist").jqGrid({
url:'manual_responses.php',
datatype: "json",
colNames:['ID','Image','Keyword','send Found','Proposed send',''],
colModel:[
{name:'item_id', index:'item_id', width:45, editable:false, hidden:true},
{name:'image', index:'image', width:45},
{name:'keyword',index:'keyword', width:100, editable: false},
{name:'item_found',index:'item_found', width:130, editable: false},
{name:'proposed_send',index:'proposed_send', width:130, editable: true, edittype:"textarea", editoptions:{rows:"2",cols:"37"}},
{name:'options',index:'options',width:40,editable: false}
],
rowNum:40,
rowList:[20,40,60],
imgpath: 'css/themes/sand/images',
sortname: 'keyword',
viewrecords: true,
sortorder: "asc",
caption:"Proposed sends",
onSelectRow: function(item_id){
if(item_id && item_id!==last_row){
jQuery("#gridlist").restoreRow(last_row);
jQuery("#gridlist").editRow(item_id,true);
last_row=item_id;
}
},
loadComplete: function(){
//alert('ok, loadComplete running');
var ids = jQuery("#gridlist").getDataIDs();
for(var i=0;i<ids.length;i++){
var cl = ids[i];
send = "<input class='sendbuttons' id='tbuttonSend"+cl+"' type='button' value='Send' /><br />";
clear = "<input class='sendbuttons' id='tbuttonClear"+cl+"' type='button' value='Send' /><br />";
jQuery("#gridlist").setRowData(ids[i],{options:send+clear})
}
},
editurl: "item_send.php",
height:400,
width:796,
reloadAfterSubmit:false
}).navGrid('#pager2',{edit:true,add:false,del:false });
$(".sendbuttons").click(function(){
alert("got to 1");
});
});
</script>
</head>
<body>
<table id="gridlist" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pager2" class="scroll" style="text-align:center;"></div>
<input type='button' class='sendbuttons' id='323423x' value='go:'/>
</body>
</html>
解决方法:
很明显,点击事件,
$(".sendbuttons").click(function(){
alert("got to 1");
});
从不开火,因为行的点击消耗它.但是,您可以在按钮中输入自己的onclick代码.
send = "<input name='send' class='tweetbuttons' id='tbuttonSend"+cl+
"' type='button' value='Send'
onclick=jQuery('#list2').saveRow("+cl+",function(){alert('made it here')},item_send); /><br />";
正如我的评论中所讨论的,我可以使用任何参数调用saveRow函数.
内容总结
以上是互联网集市为您收集整理的javascript – 如何在jqgrid中的行上自定义按钮添加脚本?全部内容,希望文章能够帮你解决javascript – 如何在jqgrid中的行上自定义按钮添加脚本?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。