Slickgrid save all data at once

走远了吗. 提交于 2019-12-22 11:26:51

问题


I am trying to save all the data in a slickgrid at once rather than one at a time, my plan was to use Saving changes in SlickGrid so my code is :

<script language='javascript' type="text/javascript">
    function saveQuote() {

    $("input[name='mydata']").val(jQuery.parseJSON(grid.getData()));
  }
</script>

with my data being a textbox ... (so I can debug and see what is happening) My Grid is empty to begin with and the user adding data(which has calculations etc) however when I press my save button and call my saveQuote no data is being presented, any one know why?


回答1:


the problem was with:

   $("input[name='mydata']").val(jQuery.parseJSON(grid.getData()));

so I replaced it with

$("input[name='mydata']").val(JSON.stringify(grid.getData()));

full code is now:

<script language='javascript' type="text/javascript">
   function saveQuote() {
    $(function() {
        $("input[name='mydata']").val(JSON.stringify(grid.getData()));
            });
}



来源:https://stackoverflow.com/questions/12674669/slickgrid-save-all-data-at-once

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!