Click here to Skip to main content
13,048,406 members (147,816 online)
Rate this:
Please Sign up or sign in to vote.
Hello friends,

I am using navGrid feature of jqGrid to add record to database.

My question is: What is the correct way to call server side function to save record to database. I am using ajax fucntion to save record. I am able to call the ajax function and then server side code.

How to pass return value back to jqgrid. I am getting error: "error Status: 'Not Found'. Error code: 404"

My code is:

                   datatype: "jsonstring",
                   contentType: "application/json; charset=utf-8",

       {add:true,edit:true,del:true,search:true,refresh:true}, // which buttons to show?
       {editCaption: 'Update Environment', beforeSubmit: validateEditData, afterSubmit: processEdit },         // edit options
       {addCaption: 'New Environment', onclickSubmit: processAdd },  // add options
       {delCaption: 'Delete Row', beforeSubmit: validateDeleteData, afterSubmit: processDelete}          // delete options

I am calling my ajax function in "processAdd" function like this:
        url: 'Environments.aspx/AddNewEnvironment',
        data: Environment,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        type: "POST",
        success: function (data) {
return [dat.result, dat.message];

Can any one tell me "How to add record using navGrid functionality? step by step?"
Posted 2-Dec-11 4:39am
Updated 2-Dec-11 5:34am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


You need to rebind JQGrid like:

you can set your Page and Method name for getting data for example
url: 'Environments.aspx/GetEnvironmentList'

Following is whole code for JQGrid
jQuery(document).ready(function () {
           url: '@Url.Action("JQGridGetGridData", "TabMaster")',
           datatype: 'json',
           mtype: 'GET',
           colNames: ['col ID', 'First Name', 'Last Name', ''],
           colModel: [
                     { name: 'colID', index: 'colID', width: 100, align: 'left', searchoptions: { sopt: ['eq', 'ne', 'cn']} },
                     { name: 'FirstName', index: 'FirstName', width: 150, align: 'left', editable: true, editrules: { required: true} },
                     { name: 'LastName', index: 'LastName', width: 150, align: 'left', editable: true },
                     { name: 'Edit', index: 'Edit', width: 70, align: 'center', editable: false, formatter: editFmatter, unformat: unformatEdit }
           pager: jQuery('#pager'),
           hidegrid: false,
           rowNum: 100,
           rowList: [10, 50, 100, 150],
           sortname: 'colID',
           sortorder: "asc",
           viewrecords: true,
           multiselect: false,
           imgpath: '@Url.Content("~/Scripts/themes/steel/images")',
           caption: 'Tab Master Information',
           editurl: '@Url.Action("JQGridEdit", "TabMaster")'
       }).navGrid('#pager', { edit: false, add: false, del: false, search: false, refresh: false });

If you would like to more help for that please feel free to ask me.

jayasankar16 21-Nov-13 0:44am
Hi i got one requirement, it's like once the records load from database to jqgrid, then i'm going for customized popup for adding record. once i add new records what ever i required then final save. if click on final save all the records should get saved in database. we have to do only client side. can any one give some code or some clues to proceed furthur
Member 2766194 15-Apr-14 13:13pm
My Grid navigation icons are not visible..images missing for the me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 28 Dec 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100