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

javascript - FlexiGrid - set width of Grid in code - Stack Overflow

programmeradmin11浏览0评论

I'm trying out Flexigrid for a new app - I'm really impressed with it but I can't find a way to set the width in code.

The main reason for this is to get the GRID (not the columns inside the grid) to align fully to the size of the window. I know, it makes a mockery of the horizontal resizer, but that's what I have to do!

FYI my set up is the following:

$(document).ready(function() {
    $("#flex1").flexigrid
    (
    {
        url: '<%= ResolveUrl("~/Data.ashx") %>?filter=none',
        dataType: 'json',
        colModel: [
        { display: '', name: 'view', width: 20, sortable: true, align: 'center' },
        { display: 'Street', name: 'Street', width: 260, sortable: true, align: 'left' },
        { display: 'Town', name: 'Town', width: 200, sortable: true, align: 'left' },
        { display: '', name:'Actions', width:30, sortable: false, align: 'center' }
        ],
        sortname: "Street",
        sortorder: "asc",
        usepager: true,
        title: 'Streets',
        useRp: true,
        rp: 15,
        showTableToggleBtn: false,
        width: 800,
        height: 200
    }
    );
});

but the following function doesn't work:

function ResizeGrid() {
    $('#flex1').flexOptions({ width:1000 }).flexReload();
}

It causes the grid to refresh, but nothing more.

I'm trying out Flexigrid for a new app - I'm really impressed with it but I can't find a way to set the width in code.

The main reason for this is to get the GRID (not the columns inside the grid) to align fully to the size of the window. I know, it makes a mockery of the horizontal resizer, but that's what I have to do!

FYI my set up is the following:

$(document).ready(function() {
    $("#flex1").flexigrid
    (
    {
        url: '<%= ResolveUrl("~/Data.ashx") %>?filter=none',
        dataType: 'json',
        colModel: [
        { display: '', name: 'view', width: 20, sortable: true, align: 'center' },
        { display: 'Street', name: 'Street', width: 260, sortable: true, align: 'left' },
        { display: 'Town', name: 'Town', width: 200, sortable: true, align: 'left' },
        { display: '', name:'Actions', width:30, sortable: false, align: 'center' }
        ],
        sortname: "Street",
        sortorder: "asc",
        usepager: true,
        title: 'Streets',
        useRp: true,
        rp: 15,
        showTableToggleBtn: false,
        width: 800,
        height: 200
    }
    );
});

but the following function doesn't work:

function ResizeGrid() {
    $('#flex1').flexOptions({ width:1000 }).flexReload();
}

It causes the grid to refresh, but nothing more.

Share Improve this question edited Nov 17, 2011 at 17:00 Jason Plank 2,3325 gold badges32 silver badges40 bronze badges asked Mar 26, 2009 at 14:01 DuncanDuncan 10.3k14 gold badges66 silver badges96 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

Despite having NO LUCK on google for about 20 minutes before posting this, Murphy's law meant that I tried another quick search just afterwards and found the answer.

Turns out that "width" should be set to 'auto' (note the quotes are vital).

$("#flex1").flexigrid
(
{
    url: '<%= ResolveUrl("~/Data.ashx") %>?filter=none',
    dataType: 'json',
    colModel: [
    { display: '', name: 'view', width: 20, sortable: true, align: 'center' },
    { display: 'Street', name: 'Street', width: 260, sortable: true, align: 'left' },
    { display: 'Town', name: 'Town', width: 200, sortable: true, align: 'left' },
    { display: '', name:'Actions', width:30, sortable: false, align: 'center' }
    ],
    sortname: "Street",
    sortorder: "asc",
    usepager: true,
    title: 'Streets',
    useRp: true,
    rp: 15,
    showTableToggleBtn: false,
    width: 'auto',
    height: 200
}
);

I'll leave this post for anyone else who has this problem.

发布评论

评论列表(0)

  1. 暂无评论