3

How to multi-select rows and send post data to a new datatable? I have an idea with this post but it does not elaborate.I was thinking of multiselecting rows and sending them posting them to a new table on the database, while deleting them from the original table, on click of either a button on the navigation bar or preferably an outside link(like the "finished" at the bottom.enter image description here

[New edit] This is how my code looks like right now.I've got it posting to a different databsae on click and after i want the selected rows to be deleted from the grid and the database. I've appended the delete function on success but i does nothing to delete. Please any suggestions?

            jQuery("#minibutton").click( function(){

    var selectedrows = $("#list").jqGrid('getGridParam','selarrrow');
if(selectedrows.length) {
for(var i=0;i<selectedrows.length; i++) {

var selecteddatais = $("#list").jqGrid('getRowData',selectedrows[i]);
        var rows=JSON.stringify(selecteddatais)
        var postArray = {json:rows};

    $.ajax({
      type: "POST",
      url: "jsonsend.php",
   data: postArray,       
   dataType: "json",
   success: function () {
                             var errors = [];
  jQuery("#list").jqGrid('getGridParam','selarrrow').each(function(index, value) {
    if (!jQuery("#list").jqGrid('delRowData', value)) errors.push(value);
  });
  if (errors.length)
  {
    alert('Already deleted or not in list on row(s): ' + errors.join(', ')); 
  }

    }

                       }); 
         } 

 }
 });
     });
</script>
Community
  • 1
  • 1
NewHistoricForm
  • 121
  • 1
  • 8
  • 26
  • I'm getting a post but it looks like this: selectedrows=%5B%5D . have no idea how to post that ona databse. – NewHistoricForm May 14 '13 at 15:35
  • Can any one suggest a direct way to do this? To simply send/post selected row data to a database and then clear those rows? an easy where I can post to php and then to mysql.Because right now the solution I have not working when posting the info to databse – NewHistoricForm May 14 '13 at 16:14
  • No one? Please any suggestions? – NewHistoricForm May 15 '13 at 06:40
  • A simple and great answer was give over here: [blog]: http://stackoverflow.com/questions/16576865/jqgrid-how-to-delete-multiple-selected-rows-after-submitting-to-a-database – NewHistoricForm May 20 '13 at 03:15

1 Answers1

2

You can enable delete button in your jqgrid and then pass the value as delData to your servlet or handler.Here i pass the value of MsgId in my servlet.Check here:

 .navGrid('#page',{edit:false,add:false,del:true,deltext:"Move to  Trash"},{},{},
            /*delete start */{
                 url: '<%=request.getContextPath() + "/MessageBoxServlet?inbox=Remove"%>',
                 closeOnEscape: true,
                 reloadAfterSubmit: true,
                 delData: {
                   MsgId: function () {
                        var sel_id = $('#list').jqGrid('getGridParam', 'selarrrow');
                        var value ="";
                        for(var a=0;a < sel_id.length;a++)
                            {
                               value = ('#list').jqGrid('getCell', sel_id[a], 'msgBoxId');

                            }

                       return value;
                   }
               },


             }
          );
Ahsan 02
  • 61
  • 2
  • 15