Search code examples
jqueryslickgrid

Slickgrid save all data at once


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?


Solution

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