如何在表单中发送Jqxgrid而不使用隐藏文本框


How to send Jqxgrid in a form without using hidden textbox?

我的CI视图由一个网格组成,数据被动态地添加到这个网格中。当单击保存按钮时,它被保存到数据库中。下面是该视图的截图。[IMG] http://i40.tinypic.com/16a7dhl.png [/IMG]

当我提交表单时,Grid数据首先存储在一个数组中,然后数组元素用分隔符连接在一起,形成一个字符串。该字符串存储在一个隐藏的文本框中,并与表单一起提交。提交后,在控制器中它们再次分离&存储在数据库中。我读到过这种方法容易出错。

是否有更好的方法来发送数组的数据表的控制器比上面的方法?我使用了Jqxgrid.

使用jqxGrid的"getrows"获取所有记录作为数组。

您可以使用数组作为字段的名称。

<input type="hidden" name="field_name[]" value="foo">
<input type="hidden" name="field_name[]" value="bar">

$post = $this->input->post();
extract($post);
foreach($field_name as $k => $v){
    $this->db->insert('tablename', array('fieldname' => $v));
}