1只有文本溢出的单元格鼠标经过才显示提示信息
$('.datagrid-cell').mouseover(function () { if (this.offsetWidth < this.scrollWidth) { var content = $(this).text(); $(this).tooltip({ content: content, trackMouse: true, onHide: function () { $(this).tooltip('destroy'); } }).tooltip('show'); } });
//一下是绑定事件位置
Easyui.$myview = $.extend({}, $.fn.datagrid.defaults.view, { onAfterRender: function (target) { $.fn.datagrid.defaults.view.onAfterRender.call(this, target); var opts = $(target).datagrid('options'); var vc = $(target).datagrid('getPanel').children('div.datagrid-view'); vc.children('div.datagrid-empty').remove(); if (!$(target).datagrid('getRows').length) { var d = $('<div class="datagrid-empty"></div>').html(opts.emptyMsg || 'no records').appendTo(vc); d.css({ position: 'absolute', left: 0, top: 50, '100%', textAlign: 'center' }); } $(target).datagrid("fixRownumber");//自适应rownumber $('.datagrid-cell').mouseover(function () {
//判断文本是否溢出 if (this.offsetWidth < this.scrollWidth) { var content = $(this).text(); $(this).tooltip({ content: content, trackMouse: true, onHide: function () { $(this).tooltip('destroy'); } }).tooltip('show'); } }); } }); Easyui.datagrid = function (/*object*/options) { var $dg = $('#' + options.datagridId); var _options = $.extend({ loadMsg: '数据加载中,请稍后……', method: 'post', pageList: [15, 20, 30, 50], pageSize: 50, toolbar: '#dg_toorbar', fit: true, pagination: true, border: false, rownumbers: true, striped: true, view: Easyui.$myview, singleSelect: true, fitColumns: true, emptyMsg: '未找到符合条件的数据', cache: false }, options); if (options.formId && $(options.formId).form('validate')) { _options.queryParams = $(options.formId).form('serialize'); } $dg.datagrid(_options); };