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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:22:07+00:00 2026-05-25T20:22:07+00:00

What I have is jqgrid which uses jQueryUI autocomplete in a column. Everything works

  • 0

What I have is jqgrid which uses jQueryUI autocomplete in a column. Everything works perfect except 1 little thing, if user choose to write “fsdfsdfsfasf” and press enter my program will of course freak out and tell me that such item does not exist.

What I want is to make some kind of validation, so if user enter some data which does not exist in autocomplete list program should automatically put autocomplete text to be "" just like here: http://view.jquery.com/trunk/plugins/autocomplete/demo/ in the “month” field.

Since I am using jQueryUI autocomplete and not jquery autocomplete i cant use the mustmatch option.

{ 
    name: 'Brand', 
    index: 'Brand', 
    align: 'left', 
    width: 50, 
    sortable: true, 
    editable: true, 
    edittype: 'text', 
    editoptions: {
        dataInit:
        function (elem) {
            $(elem).autocomplete({
                delay: 0,
                minLength: 0,
                source: '@Url.Action("GetBrands")',
                minChars: 0,
                max: 12,
                autoFill: true,
                mustMatch: true,
                matchContains: false,
                scrollHeight: 220,
                formatItem: function(data, i, total) {
                    return data[0];
                },
                select: function (event, ui) {
                    if (ui.item.value == "Opret ny Brand...") {
                        $(function () {
                            var dialogDiv = $('#dialog');
                            var viewUrl = '@Url.Action("CreateBrand")';

                            $.get(viewUrl, function (data) {
                                dialogDiv.html(data);

                                var $form = $("#updateCarForm");
                                $form.unbind();
                                $form.data("validator", null);

                                //Check document for changes
                                $.validator.unobtrusive.parse(document);

                                //Re add validation with changes
                                $form.validate($form.data("unobtrusiveValidation").options);

                                //open dialog
                                dialogDiv.dialog('open');
                            });

                        });
                    }
                }

            })
            .data("autocomplete")._renderItem = function (ul, item) {
                return $("<li></li>")
                    .data("item.autocomplete", item)
                    .append("<a><span style='display:inline-block;width:60px;'><b>" +
                        item.value + "</b></span></a>")
                    .appendTo(ul);
           };
        }
    }
},
  • 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-25T20:22:07+00:00Added an answer on May 25, 2026 at 8:22 pm

    You can implement this functionality by providing a function as an argument to the source parameter of autocomplete and doing the AJAX request yourself. Something like:

    $("#auto").autocomplete({
        source: function(request, response) {
            // Manually perform the AJAX request:
            var element = this.element;
            $.get('@Url.Action("GetBrands")', request, function (results) {
                // No results? Clear out the input field.
                if (!results.length) {
                    element.val('');
                }
                // Notify the widget of the results.
                response(results);
            });
        }
    });
    

    (Untested. You may need to tweak the AJAX call)

    I can provide a remote example if necessary, but the concept is the same with an example using a local data source: http://jsfiddle.net/andrewwhitaker/Dgfgr/

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

Sidebar

Related Questions

I have a simple custom user control that uses jqGrid. the control is as
I have a mvc3 web application which uses jqgrid extensively. I just came to
I have a jqGrid with say user information which is to be edited in
I have a jqGrid which works fine when displayed on a page on its
I have a jqgrid which works fine. However there is a constraint in my
I have a checkbox column in my JqGrid which get loaded from DB, so
I have a jqgrid that contains some data, the first column of which is
I have a jqGrid with which users will select records. A large number of
I have a asp.net webforms page in which I'm using the jqGrid component. The
I have a project in ASP.NET MVC1 using VB.NET controlers and JqGrid. it works

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.