JQGrid内联导航器的服务器端代码 [英] Server side code for JQGrid Inline navigator

查看:108
本文介绍了JQGrid内联导航器的服务器端代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在使用JQGrid显示数据库的结果。现在我需要按用户更新行。我试过使用Inline Navigator。我使用以下代码制作网格。



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");

}





现在我不知道如何编写服务器端代码来保存用户的数据库中的变化。我正在使用支持AJAX的Web服务。



这是我用来显示网格的网页服务代码:





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);
          }





我的读者课程中的C#代码(数据模型中):





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;
      }





我需要帮助:



1-我需要使用Post而不是Get吗?请注意,我在一个函数中显示和编辑网格。

2-我是否需要在Javascript中添加任何其他内容?例如编辑或恢复功能?在文档中,他们在内联编辑中编辑和恢复功能,但在内联导航中没有。

3-数据以什么格式发送到Web服务进行编辑?对于显示,它采用JQGridView格式。

4-我不知道如何在Web服务中实现UpdateGrid方法,因为我不知道Inline Navigator功能究竟在做什么,它向Web服务发送了什么数据以及什么它希望从服务器获得的数据。



我搜索了整个网络,但每个人都以不同的方式使用它。

我会感谢任何帮助。



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.

推荐答案

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

}
("#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"); }





现在我不知道如何编写服务器端代码来保存用户的数据库中的变化。我正在使用支持AJAX的Web服务。



这是我用来显示网格的网页服务代码:





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);
          }





我的读者课程中的C#代码(数据模型中):





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;
      }





我需要帮助:



1-我需要使用Post而不是Get吗?请注意,我在一个函数中显示和编辑网格。

2-我是否需要在Javascript中添加任何其他内容?例如编辑或恢复功能?在文档中,他们在内联编辑中编辑和恢复功能,但在内联导航中没有。

3-数据以什么格式发送到Web服务进行编辑?对于显示,它采用JQGridView格式。

4-我不知道如何在Web服务中实现UpdateGrid方法,因为我不知道Inline Navigator功能究竟在做什么,它向Web服务发送了什么数据以及什么它希望从服务器获得的数据。



我搜索了整个网络,但每个人都以不同的方式使用它。

我会感谢任何帮助。



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.


这篇关于JQGrid内联导航器的服务器端代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆