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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:21:33+00:00 2026-05-26T17:21:33+00:00

Is it possible to merge the Column Model javascript file and the raw data

  • 0

Is it possible to merge the Column Model javascript file and the raw data JSON response into 1 file?

Oleg – here you go:

JSON – codes.json

{
    "codes":[
        {
            "code" : "WFH - Work From Home"
        },  
        {
            "code" : "OST - Onsite"
        }
]}

dataUrl and buildSelect – this is drawing up an empty select box

    editoptions: {
        dataUrl: 'http://localhost/json/codes.json',
        type: "GET",
        dataType: "json",
        contentType: "application/x-javascript; charset=utf-8",
        async: "true",
        buildSelect: function(response){
            var s = '<select>';
            $.each(response.codes, function(index, codes){
                s.append("<option>"+codes.code+"</option>");
            });
            return s + '</select>';
        }
    }},
  • 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-26T17:21:34+00:00Added an answer on May 26, 2026 at 5:21 pm

    You should modify the code of buildSelect to about the following

    buildSelect: function (data) {
        var s = '<select>', codes, i, l, code, prop;
        if (data && data.codes) {
            codes = data.codes;
            for (i = 0, l = codes.length; i < l; i++) {
                code = codes[i];
                // enumerate properties of code object
                for (prop in code) {
                    if (code.hasOwnProperty(prop)) {
                        s += '<option value="' + prop + '">' + code[prop] + '</option>';
                        break; // we need only the first property
                    }
                }
            }
        }
        return s + "</select>";
    }
    

    Additionally you should use ajaxSelectOptions to set any options of the corresponding $.ajax request which you jqGrid if it get data from from the server. In any way you should use relative URLs like json/codes.json or /json/codes.json instead of http://localhost/json/codes.json.

    An example of ajaxSelectOptions parameter could be the following

    ajaxSelectOptions: {
        dataType: 'json',
        cache: false
    }
    

    If contentType: "application/x-javascript; charset=utf-8" is really required you can add it as additional property of ajaxSelectOptions.

    How you can see from the demo the selects will be produced correct from your JSON data by above buildSelect function. The select looks like

    <select role="select" id="2_code" name="code">
        <option value="code1" role="option">WFH - Work From Home</option>
        <option value="code2" role="option">OST - Onsite</option>
    </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to merge several JavaScript files being used on a site into
I have a video file and an audio file. Is it possible to merge
Possible Duplicate: MySQL: FULL OUTER JOIN - How do I merge one column? Real
I want to merge some of the data (3 address columns to 1 column)
Is it possible to merge the below linq query into one query? var checkBoxes
Is it possible to merge to a branch that is not a direct parent
Is it possible to merge elements using XSLT. If I have the following XML
Is it possible to merge some cells of a JTable object? (source: codeguru.com )
Is it possible to merge a range of revisions from one branch to another
Is it possible to merge changes from a central repo to a local branch

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.