Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6021785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:45:50+00:00 2026-05-23T03:45:50+00:00

My AJAX-enabled WCF service returns JSON using this contract, [DataContract] public class JQGridContract {

  • 0

My AJAX-enabled WCF service returns JSON using this contract,

[DataContract]
public class JQGridContract
{
    [DataContract]
    public class Row
    {
        [DataMember]
        public int id { get; set; }

        [DataMember]
        public List<string> cell { get; set; }

        public Row()
        {
            cell = new List<string>();
        }
    }

    [DataMember]
    public int page { get; set; }

    [DataMember]
    public int total { get; set; }

    [DataMember]
    public int records { get; set; }

    [DataMember]
    public List<Row> rows { get; set; }

    public JQGridContract()
    {
        rows = new List<Row>();
    }
}  

So each row of data in the results is untyped — a row is essentially just a List without any column names attached.

I think that makes it impossible for me to use the ‘jsonmap’ attribute of colModel? Basically I am retrieving a DataTable from the database, and then putting that DataTable into this JQGridContract form. Column information from the DataTable isnt contained in the json passed to the client, though.

Id like to be able to map a column of my underlying DataTable to a column of my jqGrid, but without the need to strongly type my data contract. Is this possible? I thought it might be using anonymous types, where a list of anonymous objects (each anonymous object being a row) that have properties corresponding to each column in the underlying DataTable, but I haven’t been able to make that work.

Thanks.

EDIT

Here is an example of want I want to achieve (using server-side code, rather than javascript).

Below is essentially a column model for a jqGrid thats done in c#:

            return new JQGridColumnCollection()
            {
                new JQGridColumn()
                {
                    DataField = "ID",     // maps to the DataTable
                    DataType = typeof(int),
                    HeaderText = "ID",
                    PrimaryKey = true,
                },
                new JQGridColumn()
                {
                    DataField = "Name",  
                    DataType = typeof(string),
                    HeaderText = "Name"
                },
                new JQGridColumn()
                {
                    DataField = "Birthdate",  
                    DataType = typeof(DateTime),
                    HeaderText = "Birth Date" 
                }                
            };

The ‘DataField’ property of each column maps that column to a column in the underyling DataTable. The order of the columns in the DataTable could be different:

DataTable table = GetDataTable(" SELECT [Birthdate], [ID], [Name] From PersonTable "); 

But regardless of how I query my database, the grid will still show up where the first column is ID, the second column is Name, and the third column is Birthdate. I dont have to change my SQL query in order to change the order of the columns in my grid.

I essentially want the equivalent of a DataField property in my client-side colModel for the jqGrid. That would require that my JSON columns are named, or that I can atleast map a jqGrid column to the numerical index of a column in the JSON data source.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:45:50+00:00Added an answer on May 23, 2026 at 3:45 am

    The JQGridContract class which you use will get the data in the format which can be read by the standard jsonReader (see here for details). Each row of data in the results is not “untyped”. It has the type “string”. There are no needs to use jsonmap. The position of the string in the row defines to which column of grid the string belong. So for the data mapping the position in the cell list should be used.

    If you use the JQGridContract class you don’t need any strongly type data conversion. You can easy convert any data type to the string and so the data of your database table to JQGridContract instance. If you do will have problems you should append your question with the colModel definition of the jqGrid which you use.

    UPDATED: It doesn’t matter in which order you use fields in the SELECT. It is only important in which order you place the data from the table variable to the instance of JQGridContract. You have a method, for example, GetUserBirthday which returns JQGridContract. The method should place in the cell list the ID converted to string first, then the Name and then the Birthdate converted in the ISO date format (yyy-mm-dd). If you want use the JQGridContract which you defines you should do this.

    By the way the DataTable in not the best way to get the data per SELECT. More effectively to use SqlCommand and SqlDataReader.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can an Ajax-enabled WCF Service pass back a DataTable as a Sys.Data.DataTable? Like this
I'm using a simple ajax-enabled WCF service. I'm creating a string of XML on
I have created an Ajax enabled WCF web service that contains this simple method:
I'm trying to follow a simple example of AJAX-enabled WCF Service like: http://www.pluralsight.com/community/blogs/fritz/archive/2008/01/31/50121.aspx I'm
In Visual Studio 2010 I created a new Ajax enabled WCF Service [ServiceContract(Namespace =
I borrowed the following code to try to make an ajax-enabled WCF service work
I created a number of standard WCF Services (Service Contract and Host (svc) are
AJAX-enabled form will only submit once using AJAX, then defaults to using a standard
I have an AJAX Enabled REST Web Service self hosted at http://localhost/machinename/ and a
I am trying to make my Ajax-enabled table pagination 508-compliant (accessible using JAWS version

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.