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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:24:09+00:00 2026-06-08T04:24:09+00:00

I’ve got a case when i need to provide a different source id based

  • 0

I’ve got a case when i need to provide a different source id based on if the user is editing or adding. My initial idea was to set a hidden field’s value using the beforeShowForm hook, but it seems that the components get initialized before the hook’s function is called. Thus I’m unable to determine what model is being created at that stage of initialization.

[A]

//initLoadNoEdit gets called... (At this point I need to know if its going to be an add/edit.)
initLoadNoEdit = function (elem) {
    if ($('#curr_action').val() == 'add') {
        createLoadNumberWidget(elem, "#Date", 'some_url');
    } else {
        createLoadNumberWidget(elem, "#modal_date", 'some_url');
    }
}

var colModel = [
        { name: 'FI_ID', index: 'FI_ID', key: true, editable: false, hidden: true, search: false },     
        { name: 'LILBP_ID', index: 'LILBP_ID', editrules: { required: true }, editoptions: { dataInit: initLoadNoEdit } }
];

//...before this gets called
var addBeforeShowOptions = function (form) {
    $('#curr_action').val('add');
}

//...or this
var editBeforeShowOptions = function (form) {
    $('#curr_action').val('edit');
}

I then tried to add an on click event on the button add/edit click of the grid, i tried .live(), .delegate(), and just a normal .click(). but had no results, the pager renders as follows..

[B]

   <td id="pager_left" align="left">
      <table cellspacing="0" cellpadding="0" border="0" class="ui-pg-table navtable" style="float:left;table-layout:auto;">
       <tbody>
        <tr>
          <td class="ui-pg-button ui-corner-all" title="Add new row" id="add_theGrid">
              <div class="ui-pg-div">
                 <span class="ui-icon ui-icon-plus"></span>
              </div>
          </td>
        </tr>
       </tbody>
      </table>
    </td>

so i tried something like

 $('#add_theGrid').live('click', function () { $('#curr_action').val('add'); }); 

 //and

 $('#pager_left').delegate('#add_theGrid','click', function () { $('#curr_action').val('add'); });

that being said… i don’t think that passing a value into a variable is the best way to go about this, as I’m sure there should be a way of me to determine from the modal, what type of modal it is? I just haven’t been able to find it yet..

  • 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-08T04:24:12+00:00Added an answer on June 8, 2026 at 4:24 am


    The form’s title text should be different between Add and Edit:

    jQuery('.ui-jqdialog-title').text()
    

    Then you can check the front of it for “Add” or “Edit”. Obviously this is not an ideal solution but it is a simple way to use data that is already on the form. I think it is a bit of a hack, though.


    A better solution is to use the jqGridAddEditBeforeInitData event that is fired before dataInit. This is one of the new triggered events in 4.3.2. Documentation is a bit sparse but if you look at the code in grid.formedit.js you can see that a frmoper parameter is passed which indicates whether the form is in “add” or “edit” mode (I added line breaks to make it easier to read):

    showFrm = $($t).triggerHandler(
                "jqGridAddEditBeforeInitData", 
                [$("#"+frmgr), frmoper]);
    

    According to the jQuery docs for triggerHandler, the second parameter is a list of extra parameters. You can then use bind to add your own event handler:

    grid.bind('jqGridAddEditBeforeInitData', function(e, form, oper) {
        alert ("Before dataInit, operation is " + oper);
        // Your code here...
    });
    

    Does that help?

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

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
i got an object with contents of html markup in it, for example: string
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to

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.