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

  • SEARCH
  • Home
  • 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 6050171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:39:32+00:00 2026-05-23T07:39:32+00:00

Here is the JQGrid setup information jQuery(document).ready(function () { jQuery(#list).jqGrid({ url: ‘/TabMaster/GetGridData’, datatype: ‘json’,

  • 0

Here is the JQGrid setup information

jQuery(document).ready(function () {
    jQuery("#list").jqGrid({
        url: '/TabMaster/GetGridData',
        datatype: 'json',
        mtype: 'GET',
        colNames: ['col ID', 'First Name', 'Last Name'],
        colModel: [
              { name: 'colID', index: 'colID', width: 100, align: 'left' },
              { name: 'FirstName', index: 'FirstName', width: 150, align: 'left', editable: true },
              { name: 'LastName', index: 'LastName', width: 300, align: 'left', editable: true },
            ],
        pager: jQuery('#pager'),
        rowNum: 4,
        rowList: [1, 2, 4, 5, 10],
        sortname: 'colID',
        sortorder: "asc",
        viewrecords: true,
        multiselect: true,
        imgpath: '/scripts/themes/steel/images',
        caption: 'Tab Master Information'
    }).navGrid('#pager', { edit: true, add: true, del: true },
    // Edit options
           {
           savekey: [true, 13],
           reloadAfterSubmit: true,
           jqModal: false,
           closeOnEscape: true,
           closeAfterEdit: true,
           url: "/TabMaster/Edit/",
           afterSubmit: function (response, postdata) {
               if (response.responseText == "Success") {
                   jQuery("#success").show();
                   jQuery("#success").html("Company successfully updated");
                   jQuery("#success").fadeOut(6000);
                   return [true, response.responseText]
               }
               else {
                   return [false, response.responseText]
               }
           }
       },
    // Add options
           {},
    // Delete options
           {url: '/TabMaster/Remove' }
           );
});

following is the details for Getting Data and Update Data using JQGrid

#region "JQGrid Actions"
            public JsonResult GetGridData(string sidx, string sord, int rows, int page)
            {
                int pageIndex = page;
                int totalRecords = Convert.ToInt32(_tabmasterService.Count());
                int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows);
                IQueryable<TabMasterViewModel> tabmasters = _tabmasterService.GetQueryTabMasterList(sidx, sord, rows, page);
                var jsonData = new
                {
                    total = totalPages,
                    page = page,
                    records = totalRecords,
                    rows = (from tm in tabmasters
                            select new
                            {
                                id = tm.colID,
                                cell = new string[] { tm.colID.ToString(), tm.FirstName, tm.LastName }
                            }).ToArray()
                };
                return Json(jsonData, JsonRequestBehavior.AllowGet);
            }
            [AcceptVerbs(HttpVerbs.Post)]
            public ActionResult Edit(int id, FormCollection updateExisting)
            {
                int _id = Convert.ToInt32(updateExisting["colID"]);
                TabMasterViewModel editExisting = new TabMasterViewModel();
                editExisting = _tabmasterService.GetSingle(x => x.colID == id);
                try
                {
                    UpdateModel(editExisting);
                    _tabmasterService.Update(editExisting);
                    return Content("Success");
                }
                catch (Exception e)
                {
                    return Content(e.Message);
                }
            }
[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Remove(string id)
        {
            List<String> ids = new List<String>(id.Split(','));
            for (int i = 0; i < ids.Count; i++)
            {
                int deleteid = Convert.ToInt32(ids[i]);
                TabMasterViewModel deleteExisting = new TabMasterViewModel();
                deleteExisting = _tabmasterService.GetSingle(x => x.colID == deleteid);
                _tabmasterService.Delete(deleteExisting);
            }
            return RedirectToAction("Index");
        }
#endregion

Note:- Get and Update is successfully working but i have problem in ADD and DELETE.
Please anybody help me to write the function for ADD and DELETE?

  • 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-23T07:39:33+00:00Added an answer on May 23, 2026 at 7:39 am

    Here is the complete solution for ADD, EDIT and DELETE
    *index.cshtml*

    jQuery(document).ready(function () {
            jQuery("#list").jqGrid({
                url: '/TabMaster/GetGridData',
                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 },
                      { name: 'LastName', index: 'LastName', width: 300, align: 'left', editable: true },
                    ],
                pager: jQuery('#pager'),
                rowNum: 4,
                rowList: [1, 2, 4, 5, 10],
                sortname: 'colID',
                sortorder: "asc",
                viewrecords: true,
                multiselect: true,
                imgpath: '/scripts/themes/steel/images',
                caption: 'Tab Master Information'
            }).navGrid('#pager', { edit: true, add: true, del: true },
            // Edit options
                {
                savekey: [true, 13],
                reloadAfterSubmit: true,
                jqModal: false,
                closeOnEscape: true,
                closeAfterEdit: true,
                url: "/TabMaster/Edit/",
                afterSubmit: function (response, postdata) {
                    if (response.responseText == "Success") {
                        jQuery("#success").show();
                        jQuery("#success").html("Company successfully updated");
                        jQuery("#success").fadeOut(6000);
                        return [true, response.responseText]
                    }
                    else {
                        return [false, response.responseText]
                    }
                }
            },
            // Add options
                 {url: '/TabMaster/Create', closeAfterAdd: true },
            // Delete options
                   {url: '/TabMaster/Remove' },
                   { closeOnEscape: true, multipleSearch: true,
                       closeAfterSearch: true
                   }
                   );
        });
    

    controller.cs

    #region "JQGrid Actions"
            public JsonResult GetGridData(string sidx, string sord, int rows, int page)
            {
                int pageIndex = page;
                int totalRecords = Convert.ToInt32(_tabmasterService.Count());
                int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows);
                IQueryable<TabMasterViewModel> tabmasters = _tabmasterService.GetQueryTabMasterList(sidx, sord, rows, page);
                var jsonData = new
                {
                    total = totalPages,
                    page = page,
                    records = totalRecords,
                    rows = (from tm in tabmasters
                            select new
                            {
                                id = tm.colID,
                                cell = new string[] { tm.colID.ToString(), tm.FirstName, tm.LastName }
                            }).ToArray()
                };
                return Json(jsonData, JsonRequestBehavior.AllowGet);
            }
            [AcceptVerbs(HttpVerbs.Post)]
            public ActionResult Edit(int id, FormCollection updateExisting)
            {
                int _id = Convert.ToInt32(updateExisting["colID"]);
                TabMasterViewModel editExisting = new TabMasterViewModel();
                editExisting = _tabmasterService.GetSingle(x => x.colID == id);
                try
                {
                    UpdateModel(editExisting);
                    _tabmasterService.Update(editExisting);
                    return Content("Success");
                }
                catch (Exception e)
                {
                    return Content(e.Message);
                }
            }
            [AcceptVerbs(HttpVerbs.Post)]
            public ActionResult Remove(string id)
            {
                List<String> ids = new List<String>(id.Split(','));
                for (int i = 0; i < ids.Count; i++)
                {
                    int deleteid = Convert.ToInt32(ids[i]);
                    TabMasterViewModel deleteExisting = new TabMasterViewModel();
                    deleteExisting = _tabmasterService.GetSingle(x => x.colID == deleteid);
                    _tabmasterService.Delete(deleteExisting);
                }
                return RedirectToAction("Index");
            }
            [AcceptVerbs(HttpVerbs.Post)]
            public ActionResult Create(FormCollection FormValue)
            {
                if (ModelState.IsValid)
                {
                    TabMasterViewModel addNew = new TabMasterViewModel();
                    addNew.FirstName = FormValue["FirstName"];
                    addNew.LastName = FormValue["LastName"];
                    _tabmasterService.Add(addNew);
                }
                return RedirectToAction("Index");
            }
            #endregion
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is client Side code: jQuery(document).ready(function(){ jQuery(#list).jqGrid({ url:'example.php', datatype: 'xml', mtype: 'GET', colNames:['Inv No','Date',
ok not sure what i'm doing wrong here: $(#list).jqGrid({ url: --URL--, datatype: 'json', mtype:
Here's my client-side code: $(#grid).jqGrid({ url: /Entry/EntryListingByBreed/, datatype: json, mtype: POST, postData: { showId:
I am using jQuery 1.4 and jqGrid 3.8 beta, Here I have used jqgrid
I'm a jQuery noob, so I'm sure I'm missing something simple here. I've got
Here's a simple question. I have a jqGrid that's working great but I want
I'm fairly new to jQuery and just started working with jqGrid. I've looked over
Folks, I am completely new to jQuery and JqGrid both. Usually I take some
I have a list of products on my site. I draw it with jqGrid.
It's an addition for previous my question about adding columns into jqGrid-based table. Here

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.