Click here to Skip to main content
15,887,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am using JQGrid for showing results from database. Now I need to update rows by user. I have tried to use Inline Navigator. I have used the following code for making the grid.

 $("#MyGrid").jqGrid({
            url: service,
            datatype: "json",
            mtype: 'GET',
            colNames: ['Col1', 'Col2'],
            colModel: [
      { name: 'Col1', index: 'Col1', sortable: true, resizable: true, editable: true, sorttype: "text" },
      { name: 'Col2', index: 'Col2', align: 'left', sortable: true, resizable: true, width: 50, editable: true },
           
            pager: '#pagerLab',
            rowNum: 1000,
            rowList: [10, 30, 100, 1000],
            sortname: 'modified',
            viewrecords: true,
            gridview: true,
             loadonce: true,        
            editurl: '/Service.svc/UpdateGrid',
        });
          jQuery("#MyGrid").jqGrid('navGrid', "#pagerLab", { edit: true, add: false, del: false, search:false });
        jQuery("#MyGrid").jqGrid('inlineNav', "#pagerLab");

}


Now I am not sure how to write the server side code to save user's changes in database. I am using AJAX enabled web service.

Here is my web service code for showing the grid:

[OperationContract]
          [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
          public JQGridViewTable MyGrid(string ID)
          {
              Reader reader = new Reader();

              return Reader.ReadDetails(ID);
          }


And my C# code in Reader class(in data model):

public JQGridViewTable ReadDetails(string ID)
      {
             JQGridViewTable table = new JQGridViewTable();
      // read data from database and store in table
          return table;
      }


I need help with:

1- Do I need to use Post instead of Get? Notice that I am displaying and editing the grid in one function.
2- Do I need to add anything else in Javascript? for example edit or restore functions? In documentations they have edit and restore functions in inline editing but not in Inline navigation.
3- In what format data is sent to web service for editing? For displaying, it is in JQGridView format.
4- I don't know how to implement UpdateGrid method in web service, because I don't know what exactly Inline Navigator functions are doing, what data it is sending to web service and what data it is expecting from server.

I have searched the whole web, but everyone is using it in a different way.
I would appreciate any help.
Posted
Updated 21-Mar-13 12:20pm
v3
Comments
[no name] 21-Mar-13 14:59pm    
The answer you get is probably going to greatly depend on which database you want to connect to. www.connectionstrings.com should lead you the way.
Norooz92 21-Mar-13 18:22pm    
Thanks for the reply, but I am not asking how to connect to database, I am just asking what formats JQGrid uses to communicate with server in inline navigator.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900