检索网格内容 [英] Retrieving contents of the grid

查看:60
本文介绍了检索网格内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jqGrid 在客户端显示值.最初,网格为空,并且用户直接内联输入数据.根据要求,用户提交表单后,我需要提交数据.

I am using jqGrid to display values on the client side. Initially the grid is empty and the user enters the data inline. According to the requirement, I need to submit the data once the user submits the form.

在提交表单之前,我打算格式化内容,以便可以将用户输入的详细信息存储在数据库中.他们可以以JSON形式获取网格数据吗?

I intend to, just prior to submitting the form, format contents so that I can store the user entered details in the database. Is their any way I can get a grid data in the form of JSON?

目前,我正在通过以下方式进行此操作:

Currently I am doing the same in the following way:

var ids = $(gridId).jqGrid('getDataIDs');
for ( var i =1; i <=ids.length; i++) {
        var id = ids[i];
        rowData = $("#"+grid).jqGrid('getRowData',id);          
    }
 //add rowData to some global object and inturn to some hidden field and sending it the server.

还有其他方法可以做到吗?

Is there any other way to do the same?

推荐答案

我建议您使用

var gridData=$("#list").jqGrid('getGridParam','data');

以从网格获取完整数据.将所有数据保存在一个JavaScript对象gridData中之后,可以按照提交给服务器之前所需的方式对其进行修改.

to get full data from the grid. After you have all the data in one JavaScript object gridData you can modify it in the way which you need prior to submitting to the server.

这篇关于检索网格内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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