【问题标题】:how to fill flexi grid using json如何使用 json 填充弹性网格
【发布时间】:2013-07-10 07:25:48
【问题描述】:

我是弹性网格的新手,想绑定数据

代码

        $(document).ready(function() {

        $(".fgrid").flexigrid({
            url: '../_AJAX/ajaxCall-InterestSubsidy.aspx',
            dataType: 'json',
            type: 'POST',
            data: { 'MODE': 'BindFlexiGrid' },
            colModel: [
                       { display: 'Id', name: 'DistrictId', width: 20, sortable: true, align: 'left' },
                       { display: 'Name', name: 'DistrictName', width: 20, sortable: true, align: 'left' }
                      ],
            sortname: "Name",
            sortorder: "asc",
            usepager: true,
            title: 'List of District',
            useRp: true,
            rp: 10,
            showTableToggleBtn: true,
            width: 805,
            height: 200

        });


    });

服务器端代码

protected void Page_Load(object sender, EventArgs e)
{
    if (Request.Form["MODE"] != null)
    {
        if (Request.Form["MODE"] == "BindGrid")
        {
            SelectState();
        }
        else if (Request.Form["MODE"] == "BindFlexiGrid")
        {
            SelectState2();
        }
    }


}



public void SelectState2()
{
    try
    {
        DataTable dt;
        DataSet ds = new DataSet();
        pList = new List<SqlParameter>();
        dt = sa.GetDataTableWithSP("SPSelectDistrictWithSelect", pList);

        Response.Write(JsonConvert.SerializeObject(dt, Formatting.Indented));
    }
    catch (Exception e)
    {

    }
}

我在弹性网格中设置了一个“数据”属性,我不知道它是否有效,但我想将一些东西传递给“ajaxCall-InterestSubsidy.aspx”,以便可以调用正确的方法。

1) 如何将某些东西(例如 Request.Form["MODE"])传递给服务器端代码?

2) 绑定这个弹性网格的正确方法是什么?

3) 使用上面的代码我无法填充这个网格

4) 谁能给我一份关于 flexi grid 的适当文档

【问题讨论】:

    标签: jquery asp.net json flexigrid


    【解决方案1】:

    查看post-json.php 的源代码。很有可能把这个例子删掉很多。

    要记住的基本事项:

    1. 需要 ajax php 页面顶部的变量。您将在查询中使用它们,Flexigrid 默认将它们发布到您的 ajax 页面。
    2. 然后,将您的查询处理为 json 响应并在该页面上回显。查看 this answer 了解 json 的结构。
    3. 您的 ajax 页面将是您在调用页面的 $(document).ready() 中设置的 Flexigrid 参数中用于 ajax url 的链接。

    【讨论】:

      猜你喜欢
      • 2013-07-31
      • 2013-06-18
      • 2017-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-15
      相关资源
      最近更新 更多