Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1098887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:38:55+00:00 2026-05-17T00:38:55+00:00

i am using Jgrid.i want when i add new row to the table each

  • 0

i am using Jgrid.i want when i add new row to the table each time it assign the new id to that row.

I am adding the row using

var AddNewRow = function(id){
                      var datarow = {Consultant:"",Role:"",Task:"",SDate:"",EDate:"",
                                       Deliverables:"",Complete:""};

                      var lastsel2 = i+1;
                      //debugger;
                      var su=jQuery("#test").addRowData(lastsel2, datarow, "last") ;
//                  if (su) { 
//                          jQuery('#test').editRow(lastsel2,true); 
//                                            
//                     
//                           }  


                      };

And my complete code is….

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
     <!--<script type="text/javascript">

     var check=\$retrivexml;
      alert(check);
      </script>-->
    <link href="../../Content/css/Style/style.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="../../Content/css/Style/jquery-ui-1.7.2.custom.css"
        type="text/css" media="screen" />
    <link rel="stylesheet" href="../../Content/css/Style/ui.jqgrid.css" type="text/css"
        media="screen" />
    <!--  <link rel="stylesheet" type="text/css" media="screen" href="../../Content/css/Style/jqModal.css" />-->
    <!--<link rel="stylesheet" type="text/css" media="screen" href="../../Content/css/Style/datePicker.css" />-->
    <!--<link href="../../Content/css/Test/jquery-ui.css" rel="stylesheet" type="text/css" />-->
    <!--<link href="../../Content/css/Test/ui.jqgrid.css" rel="stylesheet" type="text/css" />-->

    <script src="../../Content/js/Jgrid js/jquery.js" type="text/javascript"></script>
    <script src="../../Content/js/Jgrid js/grid.locale-en.js" type="text/javascript"></script>
    <script src="../../Content/js/Jgrid js/jquery.jqGrid.min.js" type="text/javascript"></script>
    <!--<script src="../../Content/js/Jgrid js/celledit.js" type="text/javascript"></script>-->
    <script src="../../Content/js/Jgrid js/ui.datepicker.js" type="text/javascript"></script>
    <script src="../../Content/js/Jgrid js/json2.js" type="text/javascript"></script>
    <script src="../../Content/js/Jgrid js/JsonXml.js" type="text/javascript"></script>
    <script src="../../Content/js/Jgrid js/grid.import.js" type="text/javascript"></script>

    <!--<script type="text/javascript" src="../../Content/js/Jgrid js/grid.base.js"></script> 
    <script type="text/javascript" src="../../Content/js/Jgrid js/grid.formedit.js"></script> -->

    <script type="text/javascript">

     jQuery(document).ready( function() {

      var i=3;  
     var grid = jQuery("#test");
            var MyExportToXml = function (grid) {
                var dataFromGrid = {row: grid.jqGrid('getGridParam', 'data') };
                var xmldata = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>\n<rows>\n' +
                              xmlJsonClass.json2xml (dataFromGrid, '\t') + '</rows>';
                alert(xmldata);
            };


    var AddNewRow = function(id){
                      var datarow = {Consultant:"",Role:"",Task:"",SDate:"",EDate:"",
                                       Deliverables:"",Complete:""};

                      var lastsel2 = i+1;
                      //debugger;
                      var su=jQuery("#test").addRowData(lastsel2, datarow, "last") ;
//                  if (su) { 
//                          jQuery('#test').editRow(lastsel2,true); 
//                                            
//                     
//                           }  


                      };

     var lastsel3;
     jQuery("#test").jqGrid({
        url:'/Content/xml/user.xml',
        //url: $!retrivexml,
     datatype: "xml",
        colNames:['Consultant','Project Role', 'Task', 'Start Date','End Date','Deliverables','Complete'],
        colModel:[
         {name:'Consultant',index:'Consultant', width:90, editable: true,edittype:"select",editoptions:{value:"K:Kin;R:Rajesh;R:Renee;S:Sandeep"}},
         {name:'Role',index:'Role', width:80, align:"right",editable:true},
         {name:'Task',index:'Task', width:80, align:"right",editable:true},
         {name:'SDate',index:'SDate', width:90,editable:true},
         {name:'EDate',index:'EDate', width:90,editable:true},
         {name:'Deliverables',index:'Deliverables', width:200, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"2",cols:"25"}},
         {name:'Complete',index:'Complete', width:60, editable: true,edittype:"checkbox",editoptions: {value:"Complete:Incomplete"}}  
        ],


        rowNum:10,
        //rowList:[10,20,30],
        pager: '#pagediv',
        sortname: 'id',
        viewrecords: true,
        sortorder: "desc",
        caption:"Project Planning",
     forceFit : false,
     cellEdit: true,
     editurl:'clientArray',
     cellsubmit: 'clientArray',
     height: "100%",

     ondblClickRow: function(id, iRow, iCol, e) {alert(iRow);}, 

     afterEditCell: function (id,name,val,iRow,iCol){     

        if(name=='SDate') {
       jQuery("#"+iRow+"_SDate","#test").datepicker({dateFormat:"yy-mm-dd"});

      }

     if(name=='EDate') {
       jQuery("#"+iRow+"_EDate","#test").datepicker({dateFormat:"yy-mm-dd"});
      }
     },


    });
    jQuery("#test").jqGrid('navGrid','#pagediv',{edit:false,add:false,del:false}).navButtonAdd('#pagediv', { caption:"New", buttonicon :'ui-icon-circle-plus', title: "Add New Row",
       onClickButton: function() {
           AddNewRow (grid);
       }
    });


    $("#export").click(function(){
                MyExportToXml (grid);
            });


      });
    </script>

</head>
<body>
    <form id="form1">
        <div align="center">
            <div id="pagediv">
            </div>
            <table id="test" align="center">
            </table>
            <input type="BUTTON" id="export" value="Export" />
        </div>
    </form>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:38:56+00:00Added an answer on May 17, 2026 at 12:38 am

    I have solved the problem using..

    i count all the row in grid and then add 1 to the count..

    onClickButton: function() {
        var last = jQuery('#test').jqGrid('getGridParam','records'); 
        AddNewRow (last);
    }
    
    var AddNewRow = function(id){
    
        var datarow = {Consultant:"",Role:"",Task:"",SDate:"",EDate:"",
                       Deliverables:"",Complete:""};
    
        var lastsel2 = parseInt(id) + 1;
    
        var su=jQuery("#test").addRowData(lastsel2, datarow, "last") ;
    
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using jqGrid plugin and I want to add onKeyPress event to each field
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using C#, I need a class called User that has a username, password, active
I'm using jqgrid to display a list of sites and I want to do
So I'm using jqGrid with my mvc.net / Ling2Sql prototype site that I'm making
I want to add an event handler to jqGrid (for the onSelectRow event) but
I'm using jqGrid3.6.5 on google hosted jQueryUI1.8.2 and jQuery1.4.2 I want to change the
I am using jqGrid and I don't want the grid to autoload. I only
Is it possible to group in jqgrid without using subgrids ? I just want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.