src/lay/modules/table.js
function(sets){
      var othis = $(this)
      ,index = othis.parents('tr').eq(0).data('index')
      ,tr = that.layBody.find('tr[data-index="'+ index +'"]')
      ,data = table.cache[that.key][index];
      
      return $.extend({
        tr: tr //行元素
        ,data: table.clearCacheKey(data) //当前行数据
        ,del: function(){ //删除行数据
          table.cache[that.key][index] = [];
          tr.remove();
          that.scrollPatch();
        }
        ,update: function(fields){ //修改行数据
          fields = fields || {};
          layui.each(fields, function(key, value){
            if(key in data){
              var templet, td = tr.children('td[data-field="'+ key +'"]');
              data[key] = value;
              that.eachCols(function(i, item2){
                if(item2.field == key && item2.templet){
                  templet = item2.templet;
                }
              });
              td.children(ELEM_CELL).html(function(){
                return templet ? function(){
                  return typeof templet === 'function' 
                    ? templet(data)
                  : laytpl($(templet).html() || value).render(data)
                }() : value;
              }());
              td.data('content', value);
            }
          });
        }
      }, sets);
    }
function(sets){
      var othis = $(this)
      ,index = othis.parents('tr').eq(0).data('index')
      ,tr = that.layBody.find('tr[data-index="'+ index +'"]')
      ,data = table.cache[that.key][index];
      
      return $.extend({
        tr: tr //行元素
        ,data: table.clearCacheKey(data) //当前行数据
        ,del: function(){ //删除行数据
          table.cache[that.key][index] = [];
          tr.remove();
          that.scrollPatch();
        }
        ,update: function(fields){ //修改行数据
          fields = fields || {};
          layui.each(fields, function(key, value){
            if(key in data){
              var templet, td = tr.children('td[data-field="'+ key +'"]');
              data[key] = value;
              that.eachCols(function(i, item2){
                if(item2.field == key && item2.templet){
                  templet = item2.templet;
                }
              });
              td.children(ELEM_CELL).html(function(){
                return templet ? function(){
                  return typeof templet === 'function' 
                    ? templet(data)
                  : laytpl($(templet).html() || value).render(data)
                }() : value;
              }());
              td.data('content', value);
            }
          });
        }
      }, sets);
    }
function ( sets ) { var othis = $ ( this ) , index = othis . parents ( 'tr' ) . eq ( 0 ) . data ( 'index' ) , tr = that . layBody . find ( 'tr[data-index="' + index + '"]' ) , data = table . cache [ that . key ] [ index ] ; return $ . extend ( { tr : tr //行元素 , data : table . clearCacheKey ( data ) //当前行数据 , del : function ( ) { //删除行数据 table . cache [ that . key ] [ index ] = [ ] ; tr . remove ( ) ; that . scrollPatch ( ) ; } , update : function ( fields ) { //修改行数据 fields = fields || { } ; layui . each ( fields , function ( key , value ) { if ( key in data ) { var templet , td = tr . children ( 'td[data-field="' + key + '"]' ) ; data [ key ] = value ; that . eachCols ( function ( i , item2 ) { if ( item2 . field == key && item2 . templet ) { templet = item2 . templet ; } } ) ; td . children ( ELEM_CELL ) . html ( function ( ) { return templet ? function ( ) { return typeof templet === 'function' ? templet ( data ) : laytpl ( $ ( templet ) . html ( ) || value ) . render ( data ) } ( ) : value ; } ( ) ) ; td . data ( 'content' , value ) ; } } ) ; } } , sets ) ; }
数据行中的事件监听返回的公共对象成员
数据行中的事件监听返回的公共对象成员