Forum

July 12th, 2025
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 generating an error with asp.net webserivice
Tags: jqgrid
27/08/2010
19:44
Avatar
saifmd4u
Member
Members
Forum Posts: 5
Member Since:
27/08/2010
sp_UserOfflineSmall Offline

The data gets returned successfully if i make a seperate  $.ajax() call and assign to grid, but path included is displaying blank grid.

I have been struggling for a while :- 

script :-

jQuery("#list1").jqGrid({        
        datatype: "json",
        mtype: 'POST',
        ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
        url: "SearchResults.asmx/Search",
       
        colNames: ['From', 'To', 'Subject', 'Sent'],
        colModel: [
        { name: 'from', index: 'from', align: 'left' },
        { name: 'to', index: 'to', align: 'left' },
        { name: 'subject', index: 'subject', align: 'left' },
        { name: 'sent', index: 'sent', align: 'left', sorttype: "date"}],
        rowNum: 10,
        rowList: [5, 10, 20, 50],
        pager: '#pager3',
        sortname: 'id',
        viewrecords: true,
        sortorder: "asc",
        loadonce: true,
        caption: 'Search Results',
        imgpath: '../App_Themes/Orange/images',
        loadError : function(xhr,status,error){
            alert('error');
            alert(status);
            alert(error);
        },
        loadComplete: function (data) {
            alert('loaded');
            alert(data);
        }
        });

c# code

 JQGridData gData = new JQGridData();
            gData.total = "1";
            gData.page = "1";
            gData.records = results.LongLength.ToString();
            gData.rows = new JQGridDataRow[results.LongLength];
            for (int i = 0; i < results.LongLength; i++)
            {
                SearchResult sr = results[i] as SearchResult;
                gData.rows[i] = new JQGridDataRow();
                gData.rows[i].id = sr.From;
                gData.rows[i].cell = new string[4];
                gData.rows[i].cell[0] = sr.From;
                gData.rows[i].cell[1] = sr.ToNames;
                gData.rows[i].cell[2] = sr.Subject;
                gData.rows[i].cell[3] = sr.Sent.ToShortDateString();
            }

Can some help ?

27/08/2010
20:17
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

You need include jsonReader like following

jsonReader: { root: "d.rows", page: "d.page", total: "d.total", records: "d.records" }

as a jqGrid parameter. Additionally

serializeGridData: function (postData) {

    return JSON.stringify(postData);

}

is also needed where JSON.stringify is from json2.js which you can download from http://www.json.org/js.html could help you.

Best regards
Oleg 

P.S. Parameter imgpath should be removed as depricated since jqGrid 3.5 (see /jqgridwiki/doku.php?id=wiki:upgrade_from_3.4.x_to_3.5)

27/08/2010
20:49
Avatar
saifmd4u
Member
Members
Forum Posts: 5
Member Since:
27/08/2010
sp_UserOfflineSmall Offline

First and foremost thank you very much for the quick response. Now its working fine.

Except if I click on any of the row in the grid only first row is getting selected. Do i need to any changes for the script.

Actually i need to perform an ajax call when a row is selected. can you please help me.

Thanks

Saif

27/08/2010
21:33
Avatar
saifmd4u
Member
Members
Forum Posts: 5
Member Since:
27/08/2010
sp_UserOfflineSmall Offline

Yes finally i have figured it out.... the issue was with the data... because the id column i have specified is not a unique column always first row is getting selected.

Now I have modified id column to be unique and its working fine now.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 994

Currently Online:
19 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