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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:59:10+00:00 2026-05-24T13:59:10+00:00

How I can differentiate in the dataInit event wether am I adding new data

  • 0

How I can differentiate in the dataInit event wether am I adding new data or editing it?

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-05-24T13:59:10+00:00Added an answer on May 24, 2026 at 1:59 pm

    It’s a good question! +1 from me for it.

    There are no direct way to detect inside of dataInit whether it is called from Add or Edit form. In the same way if you use multiple editing mode (like form editing and inline editing) and multiple searching modes (advance searching dialog and the searching toolbar) there are no direct way to detect in which place the control are used.

    As the workaround you can use the following. You can define a variable which you can set in the different value inside of an event which will be called in both Add and Edit form before the dataInit will be called. To tell the trust you have not so large choice. It’s the beforeInitData event only. So you can do like following

    var myGrid = $("#list"),
        inEdit;
    
    $("#list").jqGrid({
        // all parameters of the jqGrid definition
    });
    myGrid.jqGrid('navGrid', '#pager',
      { del: false, search: false },
      { // Edit
          recreateForm: true,
          beforeInitData: function () {
              inEdit = true;
          }
      },
      { // Add
          recreateForm: true,
          beforeInitData: function () {
              inEdit = false;
          }
      });
    

    I used recreateForm:true property additionally to be sure that on every opening of the Add or Edit grid the form created new and the dataInit be called.

    In the demo the Add form looks like

    enter image description here

    Here the dataInit for the “Notes” write just the text “in Add” in the corresponding control. The “Inv. No” is the field which hold the id. The corresponding <input> control of the Add/Edit form is disabled. So the user can’t make any changes. In case of “Add” dialog the method $.jgrid.randId() will be used to generate new unique id value.

    The corresponding Edit form are like on the picture below:

    enter image description here

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

Sidebar

Related Questions

VK_LEFT is not a character but VK_A is. How can I differentiate them? Thanks.
How can I differentiate a Workflow system from a normal application that automates some
How can I differentiate between two local branches in git ? How can I
Possible Duplicate: Differences betweeen Exception and Error How can I differentiate between Errors and
Simply put, how can I differentiate these two in test.py: python test.py 1 python
folks, How can I differentiate between error codes and status codes in case of
Hie all , is there any method in android that can differentiate the left
If I pass a number of selectors to jQuery, how can I differentiate the
I just want to know whether we can differentiate the user request. I mean,
how can I differentiate between the two, when the edit field is empty in

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.