数据未在jQGrid中显示 [英] Data not shown in jQGrid

查看:77
本文介绍了数据未在jQGrid中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Everyone,

我在应用程序中使用jQgrid,一切正常,它也获得了值(我在调试器中找到)但调试器停止时不显示数据。



这是我的代码:

JQUERY CODE:



Hello Everyone,
I am using jQgrid in an application, everything is working fine, it is also getting the value (which I had find by debugger) but data is not displayed when debugger stops.

Here is my code:
JQUERY CODE:

<script type="text/javascript">
        jQuery(document).ready(function () {
            $('#btn1').click(function () {
                debugger;
                $.extend($.jgrid.defaults,
                  { datatype: 'json' },
                  {
                      ajaxGridOptions: {
                          contentType: "application/json",
                          success: function (data, textStatus) {
                              debugger;
                              if (textStatus == "success") {
                                  debugger;
                                  var thegrid = $("#contactsList")[0];
                                  var output = eval(data.d.rows);
                                  $.map(output, function (obj) {
                                      debugger;
                                      thegrid.addJSONData(eval(obj.cell));
                                      thegrid.grid.hDiv.loading = false;
                                  });
                                  switch (thegrid.p.loadui) {
                                      case "disable":
                                          break;
                                      case "enable":
                                          $("#load_" + thegrid.p.id).hide();
                                          break;
                                      case "block":
                                          $("#lui_" + thegrid.p.id).hide();
                                          $("#load_" + thegrid.p.id).hide();
                                          break;
                                  }
                              }
                          }
                      }
                  });
                $("#contactsList").jqGrid({
                    mtype: 'POST',
                    ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
                    url: 'WebForm2.aspx/GetDataTable',
                    datatype: 'json',
                    serializeGridData: function (postData) {
                        return JSON.stringify(postData);
                    },
                    jsonReader: { repeatitems: false, root: "d.rows", page: "d.page", total: "d.total", records: "d.records" },
                    colModel: [
                        { name: 'Recognition_Type', width: 60, align: "center", hidden: false },
                        { name: 'Recognition_Number', width: 80, sortable: false, hidden: false }
                    ],
                    rowNum: 10,
                    rowList: [10, 20, 300],
                    pager: "#gridpager",
                    viewrecords: true,
                    gridview: true,
                    rownumbers: true,
                    height: 230,
                    caption: 'Reports'
                }).jqGrid('navGrid', '#gridpager', { edit: true, add: true, del: false, search: true });
            })
        });
    </script>





aspx.cs代码是这样的:





aspx.cs code is this:

public struct s_GridResult
        {
            public int page;
            public int total;
            public int record;
            public s_RowData[] rows;

        }
        public struct s_RowData
        {
            public int id;
            public string[] cell;
        }
        [WebMethod]
        public static s_GridResult GetDataTable(string _search, string nd, int rows, int page, string sidx, string sord)
        {

            int startindex = (page - 1);
            int endindex = page;
            string sql = "select Recognition_Type,Recognition_No from SIRO";

            DataTable dt = new DataTable();
            SqlConnection conn = new SqlConnection(@"Data Source=DT00432\SQLEXPRESS;Initial Catalog=testreport;Integrated Security=True");
            SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
            adapter.Fill(dt);
            s_GridResult result = new s_GridResult();
            List<s_RowData> rowsadded = new List<s_RowData>();
            int idx = 1;
            foreach (DataRow row in dt.Rows)
            {
                s_RowData newrow = new s_RowData();
                newrow.id = idx++;
                newrow.cell = new string[2];  //total number of columns  
                newrow.cell[0] = row[0].ToString();
                newrow.cell[1] = row[1].ToString();
                rowsadded.Add(newrow);
            }
            result.rows = rowsadded.ToArray();
            result.page = page;
            result.total = dt.Rows.Count;
            result.record = rowsadded.Count;
            return result;
        } 





请尽快帮助



Please help as soon as possible

推荐答案

' #btn1')。click(function(){
debugger;
('#btn1').click(function () { debugger;


.extend(


.jgrid.defaults,
{datatype:' json'},
{
ajaxGridOptions:{
contentType: application / json
success:function(data,textStatus){
debugger;
if (textStatus == success){
debugger ;
var thegrid =
.jgrid.defaults, { datatype: 'json' }, { ajaxGridOptions: { contentType: "application/json", success: function (data, textStatus) { debugger; if (textStatus == "success") { debugger; var thegrid =


这篇关于数据未在jQGrid中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆