zoukankan      html  css  js  c++  java
  • easyui datagrid 点击表头的事件

    在用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';  
                   }  
               },  
               {text:'<input id=\"text\" type=\"text\">',handler:function(){
                   return "<input type=\"text\">";
               }}  
               ],
                });
    }

    function click(){
        alert("name");
        return "<p id='na' onclick='naclick("+1+")'>name</p>";
    }

    这里利用的是datagrid的title可以用一个function生成。

    我们可以自由 的在返回值里定义我们想要的东西,用起来相当方便。

    如果不想用函数生成的话直接在column里写<p id='na' onclick='naclick()'>name</p>也一样可以生成.这个可能是easyui吧传过去的值先进性了处理之后又显示出来的

    所以我们看到的不是整个的字符串,而是经过html处理过的东西。

  • 相关阅读:
    计算机网络实验之Wireshark_DNS
    计算机网络自顶向下配套资源
    MOS_Chapter2_Process And Thread
    Leetcode 23. 合并K个升序链表
    MOS_Chapter1_Introduction
    Leetcode的开门大吉
    hexo和gitee搭建免费个人博客详细教程
    第三章 模型搭建和评估-评估
    第三章 模型搭建和评估--建模
    第二章:第四节数据可视化
  • 原文地址:https://www.cnblogs.com/monkeydai/p/4147690.html
Copyright © 2011-2022 走看看