FlexiGrid - 在代码中设置网格宽度

发布于 2024-07-15 18:24:15 字数 1179 浏览 4 评论 0原文

我正在尝试 Flexigrid 开发一个新应用 - 我对它印象深刻,但是我找不到在代码中设置宽度的方法。

这样做的主要原因是让网格(而不是网格内的列)与窗口的大小完全对齐。 我知道,它是对水平缩放器的嘲笑,但这就是我必须做的!

仅供参考,我的设置如下:

$(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
    }
    );
});

但以下功能不起作用:

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

它会导致网格刷新,但仅此而已。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青春如此纠结 2024-07-22 18:24:15

尽管在发布此内容之前在谷歌上搜索了大约 20 分钟,但墨菲定律意味着我随后尝试了另一次快速搜索并找到了答案。

事实证明,“宽度”应该设置为“自动”(注意引号至关重要)。

$("#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
}
);

我会将这篇文章留给其他遇到此问题的人。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文