学习基于jQuery的FlexiGrid工具 (七)

2014-11-24 01:40:17 · 作者: · 浏览: 17

if (pth != null) {

if (p.sortname == $(pth).attr('abbr') && p.sortname) {

this.className = 'sorted';

}

$(tdDiv).css({

textAlign: pth.align,

width: $('div:first', pth)[0].style.width

});

if (pth.hidden) {

$(this).css('display', 'none');

}

}

if (p.nowrap == false) {

$(tdDiv).css('white-space', 'normal');

}

if (this.innerHTML == '') {

this.innerHTML = ' ';

}

tdDiv.innerHTML = this.innerHTML;

var prnt = $(this).parent()[0];

var pid = false;

if (prnt.id) {

pid = prnt.id.substr(3);

}

if (pth != null) {

if (pth.process) pth.process(tdDiv, pid);

}

$(this).empty().append(tdDiv).removeAttr('width'); //wrap content

});

},

getCellDim: function (obj) {// get cell prop for editable event

var ht = parseInt($(obj).height());

var pht = parseInt($(obj).parent().height());

var wt = parseInt(obj.style.width);

var pwt = parseInt($(obj).parent().width());

var top = obj.offsetParent.offsetTop;

var left = obj.offsetParent.offsetLeft;

var pdl = parseInt($(obj).css('paddingLeft'));

var pdt = parseInt($(obj).css('paddingTop'));

return {

ht: ht,

wt: wt,

top: top,

left: left,

pdl: pdl,

pdt: pdt,

pht: pht,

pwt: pwt

};

},

addRowProp: function () {

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

$(this).click(function (e) {

var obj = (e.target || e.srcElement);

if (obj.href || obj.type) return true;

$(this).toggleClass('trSelected');

if (p.singleSelect) $(this).siblings().removeClass('trSelected');

}).mousedown(function (e) {

if (e.shiftKey) {

$(this).toggleClass('trSelected');

g.multisel = true;

this.focus();

$(g.gDiv).noSelect();

}

}).mouseup(function () {

if (g.multisel) {

g.multisel = false;

$(g.gDiv).noSelect(false);

}

}).hover(function (e) {

if (g.multisel) {

$(this).toggleClass('trSelected');

}

}, function () {});

if ($.browser.msie && $.browser.version < 7.0) {

$(this).hover(function () {

$(this).addClass('trOver');

}, function () {

$(this).removeClass('trOver');

});

}

});

},

pager: 0

};

if (p.colModel) { //create model if any

thead = document.createElement('thead');

var tr = document.createElement('tr');

for (var i = 0; i < p.colModel.length; i++) {

var cm = p.colModel[i];

var th = document.createElement('th');

th.innerHTML = cm.display;

if (cm.name && cm.sortable) {

$(th).attr('abbr', cm.name);

}

$(th).attr('axis', 'col' + i);

if (cm.align) {

th.align = cm.align;

}

if (cm.width) {

$(th).attr('width', cm.width);

}

if ($(cm).attr('hide')) {

th.hidden = true;

}

if (cm.process) {

th.process = cm.process;

}

$(tr).append(th);

}

$(thead).append(tr);

$(t).prepend(thead);

} // end if p.colmodel

//init divs

g.gDiv = document.createElement('div'); //create global container

g.mDiv = document.createElement('div'); //create title container

g.hDiv = document.createElement('div'); //create header container

g.bDiv = document.createElement('div'); //create body container

g.vDiv = document.createE