Forum
23:43
04/09/2014
I can submit my grid no problem but when adding a new row it gets the id but not the data so its null. How can I add my new row to my local dataset then post all in a batch save? I have included my code for reference.
parameters2 = {
      Â
      Â
           EmpID: "1234",
           concatProjectTask: "Development",
           TaskId: "3",
           ActivityName: "Regular",
           Sun: 0,
           Mon: 0,
           Tue: 0,
           Wed: 0,
           Thu: 0,
           Fri: 0,
           Sat: 0,
           Sun2: 0,
           Mon2: 0,
           Tue2: 0,
           Wed2: 0,
           Thu2: 0,
           Fri2: 0,
           Sat2: 0,
           Total: 0,
      Â
       position: "last",
       edit: false
   }
function NewRow2() {
       var addNewRow = new Array();
       $("#grid2").jqGrid('addRowData', '6', parameters2);
     Â
   }
 function SaveAll2() {
       var $grid = $('#grid2'),
           editingRowId,
           myEditParam = {
               keys: true,
               oneditfunc: function (id) { editingRowId = id; },
               afterrestorefunc: function (id) { editingRowId = undefined; }
           };
       var rowid = 0;
       var localGridData = new Array();
       var rows = $('#grid2').jqGrid('getDataIDs');
       for (var i = 0; i < rows.length; i++) {
           $('#grid2').jqGrid('saveRow', rows[i], false, 'clientArray');
           var data = $('#grid2').jqGrid('getGridParam', rows[i]);
           localGridData.push(data);
       }
       var dataToSend = JSON.stringify(localGridData);
       $.ajax({
           type: "POST",
           contentType: "application/json; charset=utf-8",
           url: "Employee/SaveHours",
           dataType: "json",
           data: dataToSend,
           success: function (result) {
               alert("Success");
               $('#grid').trigger('reloadGrid');
           },
           error: function (jqXHR, textStatus, errorThrown) {
               $('#' + grid[0].id + '_err').remove();
               grid.closest('div.ui-jqgrid').before(
                   '<div id="' + grid[0].id + '_err" style="max-width:' + grid[0].style.width +
                   ';"><div class="ui-state-error ui-corner-all" style="padding:0.7em;float:left;"><span class="ui-icon ui-icon-alert" ' +
                   decodeErrorMessage(jqXHR, textStatus, errorThrown) + '</span<?div<div style="clear:left"/></div>');
           }
       });
   }
14:31
Moderators
30/10/2007
Hello,
Make sure that newly added row has a uniquie id. It seems yors are not.
Â
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
19:29
04/09/2014
Fixed my save issue up to a point. Corrected code in my batch save but...when clicking my save button I can only get my current rows not my newrow I added. I see all the ID's but not sure how to get my new row added to the batch or 'clientArray' in order to save. In addition how do I add the Id's of each row including the new row to the batch?
parameters2 = {
       rowid: 'new_row',
       initdata:{
           EmpID: "1234",
           concatProjectTask: "Development",
           TaskId: "3",
           ActivityName: "Regular",
           Sun: 0,
           Mon: 0,
           Tue: 0,
           Wed: 0,
           Thu: 0,
           Fri: 0,
           Sat: 0,
           Sun2: 0,
           Mon2: 0,
           Tue2: 0,
           Wed2: 0,
           Thu2: 0,
           Fri2: 0,
           Sat2: 0,
           Total: 0
      },
       position: "last",
       edit: false
   }
function NewRow2() {
      Â
       $("#grid2").jqGrid('addRow', parameters2);
     Â
   }
12:55
Moderators
30/10/2007
Hello,
Â
You do not need to call saveRow, since addRowData add a data direct to the grid.
Not sure what is happen with your code -I'm very confused with your code.
Â
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
19 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66