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_TopicIcon
Can't get data JSON
10/10/2012
10:42
Avatar
Bulgarin
Member
Members
Forum Posts: 3
Member Since:
10/10/2012
sp_UserOfflineSmall Offline

Hello.

I tried to get data from my service and post in jqGrid.

I get data from service, but I can't post values.

Can you help me?

This is my code:

jQuery("#tblFormsGrid").jqGrid({
        url: 'MyPage.aspx?MyMethod=GetDocumentsInfo',
        datatype: 'json',
        type: 'POST',
        ajaxGridOptions: { contentType: "application/json" },
        contentType: 'application/json; charset=utf-8',
        jsonReader: {
            root: "d.rows",
            page: "d.page",
            total: "d.total",
            records: "d.records"
        },
        mtype: 'GET',
        height: 330,
        width: 740,
        colNames: ['ID', 'Name', 'Number', 'Uploaded By', 'Modified By', 'Last Modified', 'File Size', 'History'],
        colModel: [
                { name: 'id', index: 'id', width: 10, sortable: false, hidden: true },
                { name: 'name', index: 'name', width: 200, sorttype: "string" },
                { name: 'Num', index: 'Num', width: 90, sorttype: "string" },
                { name: 'uploadedBy', index: 'uploadedBy', width: 90, sorttype: "string" },
                { name: 'modifiedBy', index: 'modifiedBy', width: 90, sorttype: "string" },
                { name: 'dateModified', index: 'dateModified', width: 100, sorttype: "date" },
                { name: 'fileSize', index: 'fileSize', width: 100, sorttype: "int" },
                { name: 'btnHistory', index: 'btnHistory', width: 100, sortable: false}],
        multiselect: true,
        caption: "Forms",
        rowNum: 15,
        hiddengrid: true,
        gridview: true,
        gridComplete: function() {
            var ids = jQuery("#tblFormsGrid").jqGrid('getDataIDs');
            for (var i = 0; i < ids.length; i++) {
                var row_id = ids[i];
                var btnHis = "<span class='LinkButton' onclick="GetRowData(" + row_id + ")" >View History</span>";
                jQuery("#tblFormsGrid").jqGrid('setRowData', ids[i], { btnHistory: btnHis });
            }
        }
    });

CodeBehind:

int vetId = GetVetId();
            MyService dmsc = new MyService();
            var docs = dmsc.GetAll(param1, param2);
            var documents = docs.Data;
            List<object> listDocs = new List<object>();
            foreach (myDoc doc in documents)
            {
                listDocs.Add(new
                {
                    id = doc.Id.ToString(),
                    name = doc.Name,
                    Num = "none",
                    modifiedBy = doc.ModifiedBy,
                    uploadedBy = doc.ModifiedBy,
                    dateModified = doc.Modified,
                    btnHistory=""
                });
            }
            var result = new
            {
                page = "1",
                total = "1",
                records = "15",
                rows = listDocs
            };
            System.Web.Script.Serialization.JavaScriptSerializer oSerializer =
                                new System.Web.Script.Serialization.JavaScriptSerializer();
            object jsn = oSerializer.Serialize(result);
            Response.Write(jsn);
            Response.End();  

11/10/2012
17:22
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

I have difficulties to understand the problem.

What you want to post and from where?

Maybe you will need to look at documentation here

Regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

12/10/2012
09:09
Avatar
Bulgarin
Member
Members
Forum Posts: 3
Member Since:
10/10/2012
sp_UserOfflineSmall Offline

Hi Tony,

I read the documentation.

My service return documents' info and I add it to 'listDocs'. After, I add this list to 'result' and serealized it. This result can't add to jqgrid. And now with many changes I fix this.

But I have another problem - My grid can't refresh... I add a button to delete a file from my system. In the end of 'onclick'-method for this button I have

$.ajax({
            url: 'MyPage,
            data: "{}",
            dataType: "json",
            type: "POST",
            contentType: "application/json; charset=utf-8",
            success: function(data) {
            jQuery("#myJqGrid").jqGrid('setGridParam', { data: data }).trigger('reloadGrid');
            }
        });

And with this I get new data from codebehind method in "MyPage" (this is aspx page). 'data'-object has new values , set it to grid's data, but not refresh the grid with new values.

Can you help me?

Thanks!

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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