最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Want to stretch the last column in Flexigrid - Stack Overflow

programmeradmin3浏览0评论

I did not find any way to apply column width in flexigrid in terms of percentages.
I have given absolute lengths as follows:

colModel : [
    {display:'ISO', width:50},
    {display:'Name', width:300},
    {display:'Printable Name', width:200},
    {display:'ISO3', width:200},
    {display:'Number Code', width:100},
],

So what is happening is, when I resize the last columns the there is a white space to the right of it. Please refer screenshot.

Is there a way to make last column occupy the remaining space and rest of the columns absolute. This feature has been implemented in Flex in our app and there is no way I can know how it is done.

I did not find any way to apply column width in flexigrid in terms of percentages.
I have given absolute lengths as follows:

colModel : [
    {display:'ISO', width:50},
    {display:'Name', width:300},
    {display:'Printable Name', width:200},
    {display:'ISO3', width:200},
    {display:'Number Code', width:100},
],

So what is happening is, when I resize the last columns the there is a white space to the right of it. Please refer screenshot.

Is there a way to make last column occupy the remaining space and rest of the columns absolute. This feature has been implemented in Flex in our app and there is no way I can know how it is done.

Share Improve this question asked May 16, 2012 at 7:08 AshwinAshwin 12.4k22 gold badges85 silver badges119 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

Hiya demo http://jsfiddle/GNqZn/1/show and http://jsfiddle/GNqZn/1/

YOu probably need to write a custom function like this I wrote for this specific case in demo above:

In the demo above my table view had 700 width and 4 columns before number code hence 700/4

Read here: http://groups.google./group/flexigrid/browse_thread/thread/3da4473a5f467cea

Hope this will help you in right direction and demo will help you to play around. cheers!

D'uh this is no silver bullet but you can make it by tweaking for your specific need. :)

UPDATE 5th June To give OP a simple demo: http://jsfiddle/2TkyR/22/ or http://jsfiddle/gaNZR/11 or http://jsfiddle/gaNZR/11/show/

If I may remend it is vital if you read bit more about the plugin, play around a bit you will feel more confident.

Please see an image attached below All you need to do is add this customize function according to your needs.

Please Read this: http://flexigrid.info/ and some good tutorials & this: http://www.kenthouse./blog/2009/07/fun-with-flexigrids/

Jquery code

function GetColumnSize(percent){ 
    screen_res = (700/4)*0.95; // 700 is the width of table;
    col = parseInt((percent*(screen_res/100))); 
    if (percent != 100){ 
       // alert('foo= ' + col-18);
        return col-18; 
    }else{ 
       // alert(col);
        return col; 
    } 
} 

call it like this width : GetColumnSize(100),

   $("#flex1").flexigrid({
        url: 'post2.php',
        dataType: 'json',
        colModel : [
            {display: 'ISO', name : 'iso', width : 40, sortable : true, align: 'center'},
            {display: 'Name', name : 'name', width : 180, sortable : true, align: 'left'},
            {display: 'Printable Name', name : 'printable_name', width : 120, sortable : true, align: 'left'},
            {display: 'ISO3', name : 'iso3', width : 130, sortable : true, align: 'left', hide: true},
            {display: 'Number Code', name : 'numcode', width : GetColumnSize(100), sortable : true, align: 'right'}
            ],

2 Images below

Image 1

Image 2

发布评论

评论列表(0)

  1. 暂无评论