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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:18:32+00:00 2026-05-24T08:18:32+00:00

jqGrid add forms contains autocomplete boxes using code below. If new row is added

  • 0

jqGrid add forms contains autocomplete boxes using code below.
If new row is added to jqgrid, autocomplete fields are not cleared, the still show added row content.
Simple textbox columns are cleared properly.
How to clear autocomplete boxes also ?

var grid = $("#grid");
grid.jqGrid({
    url: 'GetData',
    datatype: "json",
    mtype: 'POST',
    scroll: 1,
    multiselect: true,
    multiboxonly: true,
    scrollingRows : true,
    autoencode: true,
    prmNames:  {id:"_rowid", oper: "_oper" }, 
    colModel: [{"label":"Artikkel","name":"Toode","edittype":"custom","editoptions":{"custom_element":function(value, options) {
return combobox_element(value, options,'54','Toode','RidG','ArtikkelDokumendiReal')}
,"custom_value":combobox_value
},"editable":true},
],
    gridview: true,
    toppager: true,
    editurl: 'Edit',
    rownumbers: true,
});

grid.navGrid("#grid_toppager", { refreshstate: 'current' },
    {},
    { url: 'AddDetail',
    editData: { _dokdata: FormData },
    savekey: [true, 13],
    recreateForm: true,
    closeOnEscape: true,
    // todo: this does not clear autocomplete boxes:
    clearAfterAdd: true,
    addedrow: 'last',
    reloadAfterSubmit: false,
    afterSubmit: function (response) { return [true, '', response.responseText] },
});

function combobox_element(value, options, width, colName, entity, andmetp) {
    var elemStr;
    if (options.id === options.name)
    // form 
        elemStr = '<div>' +
           '<input class="FormElement ui-widget-content ui-corner-all" style="vertical-align:top" size="' +
                options.size + '" value="' + value + '"/>' +
           '<button ' +
           ' style="height:21px;width:21px;" tabindex="-1" /></div>';
    else
        elemStr = '<div>' +
           '<input class="FormElement ui-widget-content " style="height:17px;vertical-align:top;width:' +
                width + 'px" value="' + value + '"/>' +
           '<button ' +
           ' style="height:21px;width:21px;" tabindex="-1" /></div>';
    var newel = $(elemStr)[0];
    setTimeout(function () {
        input_autocomplete(newel, colName, entity, andmetp, validate);
    }, 50);
    return newel;
}

function input_autocomplete(newel, colName, entity, andmetp, fvalidate) {
    var input = $("input", newel);
    input.autocomplete({
        source: 'Grid/GetLookupList'
    });
}

function combobox_value(elem, operation, value) {
    if (operation === 'get') {
        return $(elem).find("input").val();
    } else if (operation === 'set') {
        $('input', elem).val(value);
    }
}
  • 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-24T08:18:32+00:00Added an answer on May 24, 2026 at 8:18 am

    It seems to me that the problem exist because you use custom edit control (edittype:"custom", custom_element and custom_value. The <input> element which you create has currently no id. You should follow jqGrid id conversion and create the <input> element having id equal to options.id:

    function combobox_element(value, options, width, colName, entity, andmetp) {
        var elemStr, newel;
        if (options.id === options.name) {
            // form 
            elemStr = '<div>' +
               '<input class="FormElement ui-widget-content ui-corner-all"'+
               ' style="vertical-align:top"' +
               ' id="' + options.id + '"' +
               ' size="' + options.size + '" value="' + value + '"/>' +
               '<button style="height:21px;width:21px;" tabindex="-1" /></div>';
        } else {
            elemStr = '<div>' +
               '<input class="FormElement ui-widget-content "' +
               ' style="height:17px;vertical-align:top;width:' +
               width + 'px"'+
               ' id="' + options.id + '_x"' +
               ' value="' + value + '"/>' +
               '<button ' +
               ' style="height:21px;width:21px;" tabindex="-1" /></div>';
        }
        newel = $(elemStr)[0];
        setTimeout(function () {
            input_autocomplete(newel, colName, entity, andmetp, validate);
        }, 50);
        return newel;
    }
    

    UPDATED: I corrected the code above from the usage of options.id as the id of the <input> to the value options.id + "_x". The problem that the options.id will be assigned by jqGrid later to the <div> element which will be represented as newel. jQuery UI Autocomplete required that the <input> element, to which it will be connected, has an unique id so we can choose any other id as options.id to have no id duplicates.

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

Sidebar

Related Questions

jqGrid edit and add forms render every field in separate row. If there are
I'm using jqGrid plugin and I want to add onKeyPress event to each field
I am using Jqgrid 3.6 beta version with asp.net and i wanna add dynamic
I'm new to JQgrid and can't figure out how to add a default button
i am trying to display the 'add new record' display in jqgrid but it
I am working on my first implementation of a jqGrid . I am using
So I'm using jqGrid with my mvc.net / Ling2Sql prototype site that I'm making
I have a jqGrid that has add/edit dialogs with a form that's longer than
i am jsgrid i want have implemented the add row button. when i click
I'm using jqGrid to display some data on a page. Within the controller action,

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.