Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
jqGrid not displaying SQL Server data using JSON
13/03/2013
03:03
Avatar
dcary3503
New Member
Members
Forum Posts: 2
Member Since:
13/03/2013
sp_UserOfflineSmall Offline

I've been messing with this for a few days now and I'm losing my mind. I was able to get jqGrid working, using a 'local' datatype and now I'm trying to tie it to my SQL data. I get no errors, just a blank grid. I'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'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?

VB.NET code: ============ Public Function GetGridData() As JqGridData Dim sql As String = "Select unit_number, product_code, blood_type, 'No Match' scan_result From product_header Where (product_id < 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: 'Display.aspx/GetGridData', datatype: 'json', mtype: "GET", ajaxGridOptions: { contentType: 'application/json; charset=utf-8' }, serializeGridData: function (data) { return JSON.stringify(data); }, jsonReader: { root: "rows", page: "page", total: "total", records: "records", repeatitems: true }, colModel: [ {name: 'unit_number', label: 'Unit Number', width: 100, align: 'center'}, {name: 'product_code', label: 'Product Code', width: 200, align: 'center'}, {name: 'blood_type', label: 'Blood Type', width: 200, align: 'center'}, {name: 'scan_result', label: 'Scan Result', width: 200, align: 'center'} ], rowNum: 10, rowList: [10, 20, 30], sortname: 'id', sortorder: "asc", pager: "#pager", viewrecords: true, caption: 'My first grid' }).jqGrid('navGrid', '#pager', {edit: false, add: false, del: false, search: true}); });
13/03/2013
05:16
Avatar
dcary3503
New Member
Members
Forum Posts: 2
Member Since:
13/03/2013
sp_UserOfflineSmall Offline

I found some issues in my code I'm working through.  If I continue to have issues I'll re-post.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
44 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information