简体   繁体   English

如何动态绑定JQGrid

[英]How to Bind the JQGrid Dynamically

I am new to JQGrid and JQUery please give me the solution? 我是JQGrid和JQUery的新手,请给我解决方案吗?

I am developing the Sharepoint application2010 in that am using the JQGrid, i want to show the list data in the JQGrid. 我正在开发使用JQGrid的Sharepoint application2010,我想在JQGrid中显示列表数据。 for this i have the dataset, using the dataset i need to bind the JQGrid, that dataset having differnet columns. 为此,我有数据集,使用数据集我需要绑定JQGrid,该数据集具有differentnet列。

when ever we using the Noraml asp.net Gridview we can give the datasource directly like below no need to mention columns, in the same way i need to develop the JQGrid. 每当我们使用Noraml asp.net Gridview时,我们都可以像下面一样直接提供数据源,而无需提及列,就像我需要开发JQGrid一样。

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

in .cs 在.cs中

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

please help! 请帮忙!

Firs get the details about the columns and then bind. 冷杉获取有关列的详细信息,然后进行绑定。

put this in the document.ready 将此放入文档中。

$.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);

You can see the sample of JQGrid in asp.net here. 您可以在asp.net中看到JQGrid的示例。 It shows how to bind data source and column to JQGrid. 它显示了如何将数据源和列绑定到JQGrid。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM