日期:2014-05-16  浏览次数:20413 次

easyui onloadsucess方法
<table id="dg" class="easyui-datagrid" title="Messages more than 90 days old will be removed automatically." style="width:760px;height:250px">
</table> 
<script type="text/javascript"> 
   $(function(){
        $("#dg").datagrid({
            url:"../ashx/userInquirys.ashx",
            singleSelect:true,
            pagination: true,  
            pageSize:20,
            rownumbers: true,
            onLoadSuccess:function(data){          
            var panel = $(this).datagrid('getPanel');
            var tr=panel.find(".datagrid-view2 tr");
            alert(tr.length);
              tr.each(function(){
                var subject=   $(this).children('td[field="f_subject"]').children("div");
                var isview = $(this).children('td[field="f_isview"]');
                if(isview.text()=="1")
                {
                    var html=subject.html();
                    subject.html(html+"<font color='red'>New</font>");
                  }
              });
          }
</script>
运行之后 跳出了两次对话框  也就是onLoadSuccess方法执行了两次
虽然不影响结果 但是为什么会这样呢
在此谢过
easyui?

------解决方案--------------------
因为调用了两次$("#dg").datagrid()去构造表格!第一次是解析css,第二次是你的代码。去掉其中一次即可。