EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: bobee on September 30, 2012, 10:20:45 PM



Title: custom view td width calculation
Post by: bobee on September 30, 2012, 10:20:45 PM
hi guys,
first of all thx for this great plugin :D

can u guys help me how to make td width in custom view so that it can match the header' width
heres my piece o code

var custview = $.extend({}, $.fn.datagrid.defaults.view, {  
    renderRow: function(target, fields, frozen, rowIndex, rowData){  
        var cc = [];  
//        cc.push("<div style='overflow-x:auto;'>");
        if(frozen){
            for(var i=0; i<fields.length; i++){  
              var copts = $(target).datagrid('getColumnOption', fields);  
              cc.push('<td field="' + copts.field + '" style="width:160px;text-align:center">'+rowData[fields]+'</td>');  
            }
        }
        if (!frozen){  
//            
            for(i=0; i<fields.length; i++){  
                copts = $(target).datagrid('getColumnOption', fields);  
                cc.push('<td field="' + copts.field + '" style="width:100px; border-right:1px dotted #ccc">'+rowData[fields]+'</td>');  
            }  
            cc.push('</div>');  
        }  
//        cc.push("</div>");
        return cc.join('');  
    }
});

additional note -> i define style:width:100px to match the header width .. but :/ .... doesnt work
* did further investigation ... seemed that custom view' fitColumns-> true by default ...  (how to turn this thing off lol )

thx :D


Title: Re: custom view td width calculation
Post by: stworthy on October 01, 2012, 04:03:28 AM
Please refer to the renderRow implementation of default view.

http://www.jeasyui.com/extension/downloads/jquery-easyui-datagridview.zip


Title: Re: custom view td width calculation
Post by: bobee on October 02, 2012, 04:01:21 AM
hahaha :D this is what i needed :D thx mate