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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:07:37+00:00 2026-05-26T11:07:37+00:00

In my application, I use JQGrid for loading some contacts data, and when I

  • 0

In my application, I use JQGrid for loading some contacts data, and when I edit/add an entry I select the contact’s name from database and then update/add contact.

My problem is that, when I click the submit button I want to refresh the dropdown and the data that has been already entered to dispaear from dropdown list.

My code:

for colModel:

{ name: 'OwnerEmail', index: 'OwnerEmail', width: 200, align: "center", sortable: true, sorttype: 'text', editable: true, edittype: 'select', editrules: { required: true }, editoptions: { value: ownersList} },

I populate the dropdown on select row (that when I select a row, the dropdown will be refreshed)

onSelectRow: function (id) {
                var advOwners = $.ajax({
                    type: 'POST',
                    data: {},
                    url: 'MyWebService.asmx/GetOwners',
                    async: false,
                    error: function () {
                        alert('An error has occured retrieving Owners!');
                    }
                }).responseXML;

                var aux = advOwners.getElementsByTagName("string");
                ownersList = "";
                for (var i = 0; i < aux.length; i++) {
                    ownersList += aux[i].childNodes[0].nodeValue + ':' + aux[i].childNodes[0].nodeValue + '; ';
                }
                ownersList = ownersList.substring(0, ownersList.length - 2);

                jQuery("#GridView").setColProp('OwnerEmail', { editoptions: { value: ownersList} });
             }

But when I enter the edit/add form again, the dropdown it’s not refreshed, it has the items that has been loaded in the first place.

Any help?

Thanks,
Jeff

  • 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-26T11:07:37+00:00Added an answer on May 26, 2026 at 11:07 am

    I think it will be better if you would use dataUrl property of the editoptions instead of usage value property. In the case you will don’t need to use synchronous Ajax call inside of onSelectRow to get the select data manually. If the data will be needed the corresponding call will do jqGrid for you.

    The URL from dataUrl should return HTML fragment for <select> element including all <options>. So you can convert any other response from dataUrl to the required format implementing the corresponding buildSelect callback function.

    On your place I would prefer to return JSON data from the ‘MyWebService.asmx/GetOwners’ URL instead of XML data which you currently do. In the simplest case it could be web method like

    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public List<string> GetSelectData() {
        return new List<string> {
            "User1", "User2", "User3", "User4"
        };
    }
    

    If you would use HTTP GET instead of HTTP POST you should prevent usage of data from the cache by setting Cache-Control: private, max-age=0 in the HTTP header. the corresponding code will be

    [WebMethod]
    [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
    public List<string> GetSelectData() {
        HttpContext.Current.Response.Cache.SetMaxAge (new TimeSpan(0));
        return new List<string> {
            "User1", "User2", "User3", "User4"
        };
    }
    

    Per default jqGrid use dataType: "html" in the corresponding Ajax call (see the source code). To change the behavior to dataType: "json", contentType: "application/json" you should use additionally the ajaxSelectOptions parameter of jqGrid as

    ajaxSelectOptions: { contentType: "application/json", dataType: 'json' },
    

    or as

    ajaxSelectOptions: {
        contentType: "application/json",
        dataType: 'json',
        type: "POST"
    },
    

    if you will use HTTP POST which is default for ASMX web services.

    The corresponding setting for the column in the colModel will be

    edittype: 'select', editable: true,
    editoptions: {
        dataUrl: '/MyWebService.asmx/GetSelectData',
        buildSelect: buildSelectFromJson
    }
    

    where

    var buildSelectFromJson = function (data) {
            var html = '<select>', d = data.d, length = d.length, i = 0, item;
            for (; i < length; i++) {
                item = d[i];
                html += '<option value=' + item + '>' + item + '</option>';
            }
            html += '</select>';
            return html;
        };
    

    Be careful that the above code use data.d which is required in case of ASMX web services. If you would migrate to ASP.NET MVC or to WCF you will need remove the usage of d property and use data directly.

    UPDATED: Here you can download the VS2010 demo project which implements what I wrote above.

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

Sidebar

Related Questions

In my application I use JQGrid for listing some contacts. I need to show
I am wanting to expose some data service endpoints for internal application use and
I'd like to use the multisearch facility from JqGrid within an ASP.NET MVC application.
I'm using Visual Studio to create my installation package. My application use some bitmap
My application makes use of a SQLite database to store the user's inputs. The
My application use the SDCard to store data (about 100 Mb of stuff). I
Several forms from my application use the same open file dialog. I need to
In my application, I will fetch a table of data from the server side
I need some methods of storing and getting data from a file (in WIN32
I've a jqGrid-based application, and I use loadonce: true in the grid option and

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.