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 9291185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:35:22+00:00 2026-06-18T20:35:22+00:00

I am using jqGrid to show data in tabular format, using JSP and servlet

  • 0

I am using jqGrid to show data in tabular format, using JSP and servlet.

EDIT

I want to show errors from server, when operations like insert, update, delete are performed. (datatype: "xml")

JQGrid

jQuery("#list10_d").jqGrid({
                height:250,
                width:600,
                url:'Assignment?action=Assign',
                datatype: "xml",
                colNames:['Sr. No.','PID',  'DATE',  'EMPID'],
                colModel:[{name:'srNo',index:'srNo', width:30,sortable:false},
                           {name:'PID',index:'PID',width:0, sortable:true,editable:false},
                           {name:'DATE',index:'DATE', width:75,sortable:true,editable:true,editoptions: { dataInit: function(el) { setTimeout(function() { $(el).datepicker({dateFormat:"dd-M-yy",showButtonPanel: true,changeYear: true,changeMonth: true}).attr('readonly','readonly'); }, 200); }}},
                           {name:'EMPID',index:'EMPID', width:150,sortable:true,editable:true}
                           ],
                rowNum:10,
                rowList:[10,20,50,100],
                pager: '#pager10_d',
                sortname: 'PID',
                viewrecords: true,
                sortorder: "asc",

                    },
                multiselect: true,
                editurl: "Assignment?action=Edit",
                caption:"Assignment"
            } ).navGrid('#pager10_d',{edit:false,add:true,del:false,addtext:'Assign '},
                    {},
                    {modal:true,jqModal: false,closeOnEscape:true,savekey: [true,13],closeOnEscape:true, recreateForm: true,width:500,mtype:'POST', url: 'Assignment',editData:{action: 'Assign',PID: function () {return PID;}}, 
                afterSubmit: function (response) {
                        alert('After Submit \n' +'statusText: '+ response.statusText);
                        var myInfo = '<div class="ui-state-highlight ui-corner-all">'+
                                     '<span class="ui-icon ui-icon-info" ' +
                                         'style="float: left; margin-right: .3em;"></span>' +
                                     response.statusText + 'Inserted'+
                                     '</div>',
                             $infoTr = $("#TblGrid_" + $.jgrid.jqID(this.id) + ">tbody>tr.tinfo"),
                            $infoTd = $infoTr.children("td.topinfo"); 
                        $infoTd.html(myInfo);
                        $infoTr.show();

                        // display status message to 3 sec only
                        setTimeout(function () {
                            $infoTr.slideUp("slow");
                        }, 5000);

                        return [true, "", ""]; // response should be interpreted as successful
                    },
                    errorTextFormat: function (response) {
                    alert('Error Text Format: \n' +'statusText: '+ response.statusText);

                        return '<span class="ui-icon ui-icon-alert" ' +
                                     'style="float:left; margin-right:.3em;"></span>' +
                                    response.statusText;},
                    {closeOnEscape:true, recreateForm: true,mtype: 'POST',url: 'Assignment',delData: {action: 'Delete',PID: function () {return PID;}}},
                    {}) ;

Servlet Code

if(request.getParameter("action").equalsIgnoreCase("Assign"))
        {
            PID = request.getParameter("PID");
            String DATE= request.getParameter("DATE");
            String EMPID= request.getParameter("EMPID");

            String query = "insert into ASSIGN(PID,DATE,EMPID) values('"+ PID +"','"+ DATE +"','"+ EMPID"')";
            boolean b = insert.InsertData(query);
            if(b)
            {
                System.out.println("New record added successfully! : "+query);
                response.setContentType("text/xml");
                response.setCharacterEncoding("UTF-8");

                //response.sendError(200, "success");
                response.setStatus(200, "Inserted successfully");

            }
            else
            {
                System.out.println("Failed to add Record! : "+query);
                response.setContentType("text/xml");
                response.setCharacterEncoding("UTF-8");

                //response.sendError(399, "not Inserted successfully");   
                response.setStatus(404, "Error while inserting");   
            }           
        }//INSERT

for above example

  • after inserting record from jqgrid, then No message is shown in
    grid if record is inserted successfully
  • error Status: 'Unauthorized'. Error code: 401 is shown if servlet fails to insert record in database.

My Question is that:

  • after inserting record from jqgrid, if the record is inserted then how should i show message giving information to user that data is inserted.
  • and how should I give message to user that Error while inserting (which error code should i use for this?)

Thanks in advance…..

  • 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-06-18T20:35:23+00:00Added an answer on June 18, 2026 at 8:35 pm

    I suggested in the old answer and in another one to use existing hidden row of grid form (tr.tinfo) to display information which is not error. Because the answers are not well known I repeat the same information here, but I’ll try to explain all more detailed.

    First of all it’s important to understand which elements has the standard Edit/Add form. Using Developer Tools of IE or Chrome, Firebug or many other tool one can easy find out that the Add/Edit form created by jqGrid contains two hidden rows on top of the form:

    enter image description here

    The first row will be used per default as the place for error message. One can use errorTextFormat to customize the information a little.

    If the server response contains error HTTP status code (>=400) then the callback errorTextFormat will be called and you can use

    errorTextFormat: function (response) {
        return response.responseText;
    }
    

    or something like

    errorTextFormat: function (response) {
        return '<span class="ui-icon ui-icon-alert" ' +
                     'style="float:left; margin-right:.3em;"></span>' +
                    response.responseText;
    }
    

    to display error message like

    enter image description here

    In the same way one can use afterSubmit callback to display status message after submitting of edited/added data if the server response contains successful HTTP status code. The implementation of afterSubmit could be about the following

    afterSubmit: function (response) {
        var myInfo = '<div class="ui-state-highlight ui-corner-all">'+
                     '<span class="ui-icon ui-icon-info" ' +
                         'style="float: left; margin-right: .3em;"></span>' +
                     response.responseText +
                     '</div>',
            $infoTr = $("#TblGrid_" + $.jgrid.jqID(this.id) + ">tbody>tr.tinfo"),
            $infoTd = $infoTr.children("td.topinfo");
        $infoTd.html(myInfo);
        $infoTr.show();
    
        // display status message to 3 sec only
        setTimeout(function () {
            $infoTr.slideUp("slow");
        }, 3000);
    
        return [true, "", ""]; // response should be interpreted as successful
    }
    

    The code will display the status message for 3 sec only abd then uses jQuery.slideUp animation to hide it. It will look like

    enter image description here

    I hope it’s what you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using jqGrid to show data in tabular format, using JSP and servlet.
I am using JQGRID for displaying data in tabular format. I have successfully accessed
jqGrid tree nodes are read from server using json data. Click in node reads
jqgrid is used to show stock status from server. Data is retrieved in json
I am using jqgrid to display data i need Click Here to Edit in
1) I am using the jqgrid plugin to show results from different selections a
jQgrid row is edited using inline editing mode. Pressing Enter sends data to server
Question : using jqgrid to show data of a table. table has foreign key
I'm using jqgrid 3.8.2, I'm trying to use below code to reload data from
I am using jqGrid . I am loading the data into the grid from

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.