jquery flexigrid 增加行双击事件

 

jquery flexigrid 增加行双击事件

1、在jquery.flexigrid.js文件中添加如下代码:

            addRowProp: function() {

                var $gF = this.rowProp;

                $('tbody tr', g.bDiv).each(

                    function() {

                        $("input.itemchk", this).each(function() {

                            var ptr = $(this).parent().parent().parent();

                            $(this).click(function() {

                                if (this.checked) {

                                    ptr.addClass("trSelected");

                                }

                                else {

                                    ptr.removeClass("trSelected");

                                }

                                if (p.onrowchecked) {

                                    p.onrowchecked.call(this);

                                }

                            });

                        });

                        $gF.call(this);

                                               

                       //---------添加行双击事件 ------------

                            $(this).dblclick(   

                             function (e) {

                                 if (p.onRowDblclick){

                                 p.onRowDblclick.call(this);

                                 }

                              }   

                         );

                     //------------------------------

                        

                    }

                );

                $gF = null;

            },

 

 

2、在文件最后添加方法:

//---------添加行双击事件 ------------

function callRowDblclick(){

  if( $(this).attr("class") == "trSelected" ){

      $(this).attr("class","");

      $(this).find('input:checkbox').first().attr("checked", false);

  }

  else{

      $(this).attr("class","trSelected");

      $(this).find('input:checkbox').first().attr("checked", true);      

  }

 

  //-------------获取行数据-------------

      var rowData = "";

      $.each($(this).find('div'),function(i){

         rowData+=$(this).text()+",";   

      });   

      //alert( rowData );

  //---------------------------------------

}

 //--------------------------------------------------------

 

3、在页面flexigrid({})中增加属性

onRowDblclick : callRowDblclick, // 添加行双击事件

onSuccess : onSuccess, // 成功后执行,添加行"操作"

rowhandler : false,

rowbinddata : true

相关推荐