簡體   English   中英

如何動態綁定JQGrid

[英]How to Bind the JQGrid Dynamically

我是JQGrid和JQUery的新手,請給我解決方案嗎?

我正在開發使用JQGrid的Sharepoint application2010,我想在JQGrid中顯示列表數據。 為此,我有數據集,使用數據集我需要綁定JQGrid,該數據集具有differentnet列。

每當我們使用Noraml asp.net Gridview時,我們都可以像下面一樣直接提供數據源,而無需提及列,就像我需要開發JQGrid一樣。

<asp:Gridview runat="server" id="GvSample"/>

在.cs中

GVSample.datasource=ds;
gvSample.databind();

請幫忙!

冷杉獲取有關列的詳細信息,然后進行綁定。

將此放入文檔中。

$.ajax(
    {
       type: "POST",
       url: "SomeUrl/GetColumnsAndData",
       data: "",
       dataType: "json",
       success: function(result)
       {
            colD = result.colData;
            colN = result.colNames;
            colM = result.colModel;

            jQuery("#list").jqGrid({
                jsonReader : {
                    cell: "",
                    id: "0"
                },
                url: 'SomeUrl/Getdata',
                datatype: 'jsonstring',
                mtype: 'POST',
                datastr : colD,
                colNames:colN,
                colModel :colM,
                pager: jQuery('#pager'),
                rowNum: 5,
                rowList: [5, 10, 20, 50],
                viewrecords: true
            })
       },
       error: function(x, e)
       {
            alert(x.readyState + " "+ x.status +" "+ e.msg);   
       }
    });
setTimeout(function() {$("#list").jqGrid('setGridParam',{datatype:'json'}); },50);

您可以在asp.net中看到JQGrid的示例。 它顯示了如何將數據源和列綁定到JQGrid。

http://www.trirand.net/demoaspnet.aspx

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM