<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: jqGrid not displaying SQL Server data using JSON</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-not-displaying-sql-server-data-using-json</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/jqgrid-not-displaying-sql-server-data-using-json/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>dcary3503 on jqGrid not displaying SQL Server data using JSON</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-not-displaying-sql-server-data-using-json#p28436</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-not-displaying-sql-server-data-using-json#p28436</guid>
        	        	<description><![CDATA[<p>I found some issues in my code I&#39;m working through.&#160; If I continue to have issues I&#39;ll re-post.</p>
]]></description>
        	        	<pubDate>Wed, 13 Mar 2013 05:16:47 +0200</pubDate>
        </item>
        <item>
        	<title>dcary3503 on jqGrid not displaying SQL Server data using JSON</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-not-displaying-sql-server-data-using-json#p28435</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-not-displaying-sql-server-data-using-json#p28435</guid>
        	        	<description><![CDATA[<p>I&#39;ve been messing with this for a few days now and I&#39;m losing my mind.  I  was able to get jqGrid working, using a &#39;local&#39; datatype and now I&#39;m  trying to tie it to my SQL data.  I get no errors, just a blank grid.   I&#39;ve searched the web and tried numerous examples with no luck.  The  grid displays and the column headers appear, just no data.  I also  receive no js errors.  I&#39;m not interested in paging, sorting, searching,  etc... at this point.  Just need to get the data displaying.  Can  someone point me in the right direction?</p>
</p>
<pre class="default prettyprint prettyprinted"><p><input type='button' class='sfcodeselect' name='sfselectit9719' value='Select Code' data-codeid='sfcode9719' /></p><div class='sfcode' id='sfcode9719'>VB.NET code:
============
Public Function GetGridData() As JqGridData
    Dim sql As String = "Select unit_number, product_code, blood_type, &#39;No Match&#39; scan_result From product_header Where (product_id &#60; 20) Order By 1, 2, 3"

    Dim dt As New DataTable()
    Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("conn").ConnectionString)
    Dim adapter As New SqlDataAdapter(sql, conn)
    adapter.Fill(dt)

    Dim result As New JqGridData()
    Dim gridRows As New List(Of TableRow)()
    Dim idx As Integer = 1

    For Each row As DataRow In dt.Rows
        Dim newrow As New TableRow()
        newrow.id = idx
        newrow.cell = New List(Of String)(4)
        newrow.cell(0) = row(0).ToString()
        newrow.cell(1) = row(1).ToString()
        newrow.cell(2) = row(2).ToString()
        newrow.cell(3) = row(3).ToString()
        gridRows.Add(newrow)
    Next

    result.total = 2
    result.page = 1
    result.records = gridRows.Count
    result.rows = gridRows

    Return result
End Function

Public Class TableRow

    Private m_id As Integer
    Private m_cell As List(Of String)

    Public Property id() As Integer
        Get
            Return m_id
        End Get
        Set(ByVal value As Integer)
            m_id = value
        End Set
    End Property

    Public Property cell() As List(Of String)
        Get
            Return m_cell
        End Get
        Set(ByVal value As List(Of String))
            m_cell = value
        End Set
    End Property

End Class

Public Class JqGridData

    Private m_total As Integer
    Private m_page As Integer
    Private m_records As Integer
    Private m_rows As List(Of TableRow)

    Public Property total() As Integer
        Get
            Return m_total
        End Get
        Set(ByVal value As Integer)
            m_total = value
        End Set
    End Property

    Public Property page() As Integer
        Get
            Return m_page
        End Get
        Set(ByVal value As Integer)
            m_page = value
        End Set
    End Property

    Public Property records() As Integer
        Get
            Return m_records
        End Get
        Set(ByVal value As Integer)
            m_records = value
        End Set
    End Property

    Public Property rows() As List(Of TableRow)
        Get
            Return m_rows
        End Get
        Set(ByVal value As List(Of TableRow))
            m_rows = value
        End Set
    End Property

End Class

js code:
========
$(document).ready(function(){
    $("#list").jqGrid({
        url: &#39;Display.aspx/GetGridData&#39;,
        datatype: &#39;json&#39;,
        mtype: "GET",
        ajaxGridOptions: { contentType: &#39;application/json; charset=utf-8&#39; },
        serializeGridData: function (data) {
            return JSON.stringify(data);
        },
        jsonReader: {
            root: "rows",
            page: "page",
            total: "total",
            records: "records",
            repeatitems: true
        },
        colModel: [
            {name: &#39;unit_number&#39;, label: &#39;Unit Number&#39;, width: 100, align: &#39;center&#39;},
            {name: &#39;product_code&#39;, label: &#39;Product Code&#39;, width: 200, align: &#39;center&#39;},
            {name: &#39;blood_type&#39;, label: &#39;Blood Type&#39;, width: 200, align: &#39;center&#39;},
            {name: &#39;scan_result&#39;, label: &#39;Scan Result&#39;, width: 200, align: &#39;center&#39;}
        ],
        rowNum: 10,
        rowList: [10, 20, 30],
        sortname: &#39;id&#39;,
        sortorder: "asc",
        pager: "#pager",
        viewrecords: true,
        caption:  &#39;My first grid&#39;
    }).jqGrid(&#39;navGrid&#39;, &#39;#pager&#39;, {edit: false, add: false, del: false, search: true});
});</div></pre>
]]></description>
        	        	<pubDate>Wed, 13 Mar 2013 03:03:47 +0200</pubDate>
        </item>
</channel>
</rss>