Bouilleoliv / flexigrid

Automatically exported from code.google.com/p/flexigrid
0 stars 0 forks source link

Some colModel additional parameters #27

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Example :
   ...
   colModel:[{
       display:'Header Caption',
       name:'colname',
       width:30,
       sortable:false,
       align:'left', // text align for row cells

// new paramaters
       undragable:true, // disables column drag-drop set true or false
       unresizeable : true, // disables column resizing, true or false
       headerAlign:'right' // text align for header cell, default 'center'
   },
   ... 

*) headerAlign 
=============================================
1.
find 
    var cm = p.colModel[i], th = document.createElement('th');
then put this code under it
    th.align = cm.headerAlign ? cm.headerAlign : 'center'; 
code
    var cm = p.colModel[i], th = document.createElement('th');
    th.align = cm.headerAlign ? cm.headerAlign : 'center';
2.
find 
    if (cm.align) {
    th.align = cm.align;
    }
replace it with
    if (cm.align) {
    th.calign = cm.calign; // <-- patched here
    }
3.
find 
   //add cell
   $('thead tr:first th',g.hDiv).each (
    function () {
    var td = document.createElement('td'), 
            idx = $(this).attr('axis').substr(3);
            td.align = this.align;
            td.innerHTML = row.cell[idx];
        $(tr).append(td);
        td = null
        }
   );
replace with
   //add cell
   $('thead tr:first th',g.hDiv).each (
    function () {
    var td = document.createElement('td'), 
            idx = $(this).attr('axis').substr(3);
            td.align = this.calign; // <-- patched here
            td.innerHTML = row.cell[idx];
        $(tr).append(td);
        td = null
    }
   );
4. 
find
    $('thead tr:first th',g.hDiv).each(function () {        
    var td = document.createElement('td'), 
            idx = $(this).attr('axis').substr(3);
    td.align = this.align;
    td.innerHTML = $("cell:eq("+ idx +")",robj).text();
    $(tr).append(td);
    td = null
    });
replace with
    $('thead tr:first th',g.hDiv).each(function () {        
    var td = document.createElement('td'), 
            idx = $(this).attr('axis').substr(3);
    td.align = this.calign; // <-- patched here
    td.innerHTML = $("cell:eq("+ idx +")",robj).text();
    $(tr).append(td);
    td = null
    });

5. 
find
    $(tdDiv).css({textAlign:pth.align,width:$('div:first',pth)[0].style.width});

replace with
    $(tdDiv).css({textAlign:pth.calign,width: $('div:first',pth)[0].style.width});

6. done

-------------------------
*) undragable
============================
1.
find 
    var cm = p.colModel[i], th = document.createElement('th');
then put this code under it
    th.undrag = cm.undragable ? true : false;
code
    var cm = p.colModel[i], th = document.createElement('th');
    th.undrag = cm.undragable ? true : false;

2.
find

thdiv.innerHTML = this.innerHTML;
$(this).empty().append(thdiv).removeAttr('width')
.mousedown(function(e){
    g.dragStart('colMove',e,this)
}).hover(function(){

replace with

thdiv.innerHTML = this.innerHTML;
var me = this; // <-- patched here
if(me.undrag) me.style.cursor = 'default'; // <-- patched here
$(this).empty().append(thdiv).removeAttr('width')
.mousedown(function(e){                     if(!me.undrag) // <-- patched here
    g.dragStart('colMove',e,this)
}).hover(function(){
   if(me.undrag) { // <-- patched here
    $(g.nDiv).hide(); // <-- patched here
    $(g.nBtn).hide(); // <-- patched here
    return // <-- patched here
   }; // <-- patched here
3. done

Original issue reported on code.google.com by batharak...@gmail.com on 14 Apr 2011 at 10:43

GoogleCodeExporter commented 8 years ago
here the patched file

Original comment by batharak...@gmail.com on 14 Apr 2011 at 10:58

Attachments:

GoogleCodeExporter commented 8 years ago
I did the headerAlign patch using much less modifications (and add a titleAlign 
also)

Header Alignment: (about line 698 - you can use a global value on parameter, or 
set columns one by one, default = center)

if (cm.align) {
  th.align = cm.align;
}
th.halign = cm.headerAlign? cm.headerAlign: p.headerAlign? p.headerAlign: 
'center'; // PATCH SG#1
if (cm.width) {
  $(th).attr('width', cm.width);
}

and (about line 815):

$(thdiv).css({
  textAlign: this.halign, // this.align, // PATCH SG#1
  width: this.width + 'px'
});
thdiv.innerHTML = this.innerHTML;

Title Alignment (about line 1061):

g.mDiv.className = 'mDiv';
g.mDiv.innerHTML = '<div class="ftitle">' + p.title + '</div>';
g.mDiv.style.textAlign = p.titleAlign? p.titleAlign: 'left'; // PATCH SG#2          
$(g.gDiv).prepend(g.mDiv);

Original comment by harrypit...@gmail.com on 11 Jul 2012 at 3:18