关于网友提出的“ 用过flexiGrid插件的请进。”问题疑问,本网通过在网上对“ 用过flexiGrid插件的请进。”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: 用过flexiGrid插件的请进。
描述: 如题,怎么给flexigrid 首列添加checkbox。。网上的伪代码太多了,我都试过了,不行。
解决方案1: 附上修改后的js代码
/*
* Flexigrid for jQuery - New Wave Grid
*<>
* Copyright (c) 2008 Paulo P. Marinas (webplicity.net/flexigrid)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* $Date: 2008-07-14 00:09:43 +0800 (Tue, 14 Jul 2008) $
*/
(function($) {
$.addFlex = function(t, p) {
if (t.grid) return false; //return if already exist
// apply default properties
p = $.extend({
height: 200, //default height
width: 'auto', //auto width
striped: true, //apply odd even stripes
novstripe: false,
minwidth: 30, //min width of columns<>
minheight: 80, //min height of columns
resizable: true, //resizable table
url: false, //ajax url
method: 'POST', // data sending method
dataType: 'json', // type of data loaded
errormsg: 'Connection Error',
usepager: true, //
nowrap: true, //
page: 1, //current page
total: 1, //total pages
useRp: true, //use the results per page select box
rp: 15, // results per page
rpOptions: [10, 15, 20, 25, 40],
title: false,
pagestat: '显示 {from} 到 {to} 条, 共 {total} 条记录',
procmsg: '数据获取中 ...',
query: '',
qtype: '',
nomsg: '没有数据',
minColToggle: 1, //minimum allowed column to be hidden
showToggleBtn: true, //show or hide column toggle popup
hideOnSubmit: true,
autoload: false,
blockOpacity: 0.5,
onToggleCol: false,
onChangeSort: false,
onSuccess: false,
onSubmit: false, // using a custom populate function
addcheck: false
}, p);
$(t)
.show() //show if hidden
.attr({ cellPadding: 0, cellSpacing: 0, border: 0 }) //remove padding and spacing
.removeAttr('width') //remove width properties
;
/>
//create grid class
var g = {
hset: {},
rePosDrag: function() {
var cdleft = 0 - this.hDiv.scrollLeft;
if (this.hDiv.scrollLeft > 0) cdleft -= Math.floor(p.cgwidth / 2);
$(g.cDrag).css({ top: g.hDiv.offsetTop + 1 });
var cdpad = this.cdpad;
$('div', g.cDrag).hide();
$('thead tr:first th:visible', this.hDiv).each
(
function() {
var n = $('thead tr:first th:visible', g.hDiv).index(this);
var cdpos = parseInt($('div', this).width());
var ppos = cdpos;
if (cdleft == 0)
cdleft -= Math.floor(p.cgwidth / 2);
cdpos = cdpos + cdleft + cdpad;
$('div:eq(' + n + ')', g.cDrag).css({ 'left': cdpos + 'px' }).show();
cdleft = cdpos;
}
);<>
},
fixHeight: function(newH) {
newH = false;
if (!newH) newH = $(g.bDiv).height();
var hdHeight = $(this.hDiv).height();
$('div', this.cDrag).each(
function() {
$(this).height(newH + hdHeight);
}
);
var nd = parseInt($(g.nDiv).height());
if (nd > newH)
$(g.nDiv).height(newH).width(200);
else
$(g.nDiv).height('auto').width('auto');
$(g.block).css({ height: newH, marginBottom: (newH * -1) });
var hrH = g.bDiv.offsetTop + newH;
if (p.height != 'auto' && p.resizable) hrH = g.vDiv.offsetTop;
$(g.rDiv).css({ height: hrH });
},
dragStart: function(dragtype, e, obj) { //default drag function start
if (dragtype == 'colresize') //column resize
{
$(g.nDiv).hide(); $(g.nBtn).hide();
var n = $('div', this.cDrag).index(obj);
var ow = $('th:visible div:eq(' + n + ')', this.hDiv).width();
$(obj).addClass('dragging').siblings().hide();
$(obj).prev().addClass('dragging').show();
this.colresize = { startX: e.pageX, ol: parseInt(obj.style.left), ow: ow, n: n };
$('body').css('cursor', 'col-resize');
}
else if (dragtype == 'vresize') //table resize
{
var hgo = false;
$('body').css('cursor', 'row-resize');
if (obj) {
hgo = true;
$('body').css('cursor', 'col-resize');
}
this.vresize = { h: p.height, sy: e.pageY, w: p.width, sx: e.pageX, hgo: hgo };
}
else if (dragtype == 'colMove') //column header drag
{
$(g.nDiv).hide(); $(g.nBtn).hide();
this.hset = $(this.hDiv).offset();
this.hset.right = this.hset.left + $('table', this.hDiv).width();
this.hset.bottom = this.hset.top + $('table', this.hDiv).height();
this.dcol = obj;
this.dcoln = $('th', this.hDiv).index(obj);
this.colCopy = document.createElement("div");
this.colCopy.className = "colCopy";
this.colCopy.innerHTML = obj.innerHTML;
if ($.browser.msie) {
this.colCopy.className = "colCopy ie";
}
$(this.colCopy).css({ position: 'absolute', float: 'left', display: 'none', textAlign: obj.align });
$('body').append(this.colCopy);
$(this.cDrag).hide();
}
$('body').noSelect();
},
以上介绍了“ 用过flexiGrid插件的请进。”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/2130144.html