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();
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.