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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:04:07+00:00 2026-06-12T22:04:07+00:00

i am using spring 3 with jqgrid Everything is working fine except load data

  • 0

i am using spring 3 with jqgrid Everything is working fine except load data into select option from controller i am try to load into jsion Array object and send to jsp page but i am unable to load value to select option using

(editoptions: {dataUrl:"location/role.do")

please see my code which and help me out

my controller class is

@Controller
@RequestMapping("/location")
public class AddCenterLocation {

    @Autowired
    private RecoupService recoupService;

    @RequestMapping(method = RequestMethod.GET)
    public @ResponseBody
    CustomCenterLocationResponse getAll() {
        List<? extends CenterLocation> users = recoupService.getCenter();
        response.setRows(users);
        response.setRecords(String.valueOf(users.size()));
        response.setPage("1");
        response.setTotal("10");
        return response;
    }

    @RequestMapping(value = "/role", method = RequestMethod.GET)
    public @ResponseBody
    CustomGenericResponse role(HttpServletRequest request, HttpServletResponse response) {
        JSONObject jsonArray = new JSONObject();
        try {
            List<CenterLocation> users = recoupService.getCenter();
            for (CenterLocation harbour : users) {
                jsonArray.put(harbour.getCenterId(), harbour.getCenterAddress());
            }
            response.getWriter().write(jsonArray.toString());
        } catch (Exception exception) {
            System.out.println("error is " + exception);
        }
        return null;

    }

this is my jsp page

jq(function() {
    jq("#grid").jqGrid({
        url:'location.do',
        datatype: 'json',
        mtype: 'GET',
        colNames:['Id', 'Center Name', 'Address','Country','State','City','Pin Code','Land Line No','Mobile No','Role'],
        colModel:[
            {name:'id',index:'id', width:55,editable:false,editoptions:{readonly:true,size:10},hidden:true},
            {name:'centerName',index:'centerName', width:100,editable:true, editrules:{required:true}, editoptions:{size:10}},
            {name:'centerAddress',index:'centerAddress', width:100,editable:true, editrules:{required:true}, editoptions:{size:10}},
            {name:'centerCountry',index:'centerCountry', width:100,editable:true, editrules:{required:true}, editoptions:{size:10}},
            {name:'centerState',index:'centerState', width:100,editable:true, editrules:{required:true}, editoptions:{size:10}},
            {name:'centerCity',index:'centerCity', width:100,editable:true, editrules:{required:true}, editoptions:{size:10}},
            {name:'centerPinCode',index:'centerPinCode', width:100,editable:true, editrules:{required:true}, editoptions:{size:10}},
            {name:'landLineNo',index:'landLineNo', width:100,editable:true, editrules:{required:true}, editoptions:{size:10}},
            {name:'mobileNo',index:'mobileNo', width:100,editable:true, editrules:{required:true}, editoptions:{size:10}},
            { name: 'Slger', index: 'Slger', editable: true, edittype: "select",
                editoptions: {dataUrl:"location/role.do",
                    buildSelect: function (data) {
                        var response = jQuery.parseJSON(data.responseText);
                        var s = '<select>';
                        if (response && response.length) {
                            for (var i = 0, l = response.length; i < l; i++) {
                                var ri = response[i];
                                s += '<option value="' + ri + '">' + ri + '</option>';
                            }
                        }
                        return s + "</select>";
                    }
                }
            }

        ],
        postData: { 

        },
        rowNum:20,
        rowList:[20,40,60],
        height: 400,
        autowidth: true,
        rownumbers: true,
        pager: '#pager',
        sortname: 'id',
        viewrecords: true,
        sortorder: "asc",
        caption:"Users",
        emptyrecords: "Empty records",
        loadonce: false,
        loadComplete: function() {
        },
        jsonReader : {
            root: "rows",
            page: "page",
            total: "total",
            records: "records",
            repeatitems: false,
            cell: "cell",
            id: "id"
        }
    });
    jq("#grid").jqGrid('navGrid','#pager',
    {edit:false,add:false,del:false,search:true},
    { },
    { },
    { }, 
    { 
        sopt:['eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew'],
        closeOnEscape: true, 
        multipleSearch: true, 
        closeAfterSearch: true }
);



    jq("#grid").navButtonAdd('#pager',
    {   caption:"Add", 
        buttonicon:"ui-icon-plus", 
        onClickButton: addRow,
        position: "last", 
        title:"", 
        cursor: "pointer"
    } 
);

    jq("#grid").navButtonAdd('#pager',
    {   caption:"Edit", 
        buttonicon:"ui-icon-pencil", 
        onClickButton: editRow,
        position: "last", 
        title:"", 
        cursor: "pointer"
    } 
);

    jq("#grid").navButtonAdd('#pager',
    {   caption:"Delete", 
        buttonicon:"ui-icon-trash", 
        onClickButton: deleteRow,
        position: "last", 
        title:"", 
        cursor: "pointer"
    } 
);

    jq("#btnFilter").click(function(){
        jq("#grid").jqGrid('searchGrid',
        {multipleSearch: false, 
            sopt:['eq']}
    );
    });

    // Toolbar Search
    jq("#grid").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch:"cn"});

});
  • 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-12T22:04:08+00:00Added an answer on June 12, 2026 at 10:04 pm

    first jackson lib is import into lib folder for send json data to jsp page.
    then
    create two pojo class this is only for demo you can change as your requirement

    public class Location {

    List role;

     //setter getter
    

    }

    public class Role
    {

    private String id;
    private String name;
    

    //setter getter

    }

    this is the controller request

    @RequestMapping(value = “/role”, method = RequestMethod.GET)

    public @ResponseBody
    Location role(HttpServletResponse response) {
    
        System.out.println("name");
        Location shop = new Location();
        List<Role> list = new ArrayList<Role>();
        Role role = new Role();
        role.setId("abc");
        role.setName("abc");
        list.add(role);
        Role role1 = new Role();
        role1.setId("abc1");
        role1.setName("abc1");
        list.add(role1);
        shop.setRole(list);
        return shop;
    
    }
    

    jsp page

    modify select portion of jqgrid

    { name: 'name', index: 'name', editable: true, edittype: "select",
     editoptions: {dataUrl:"location/role.do", 
    buildSelect: function (role) 
    { 
    var data = jQuery.parseJSON(role); 
    var s = '<select>'; 
    for (var i = 0; i < data.role.length; i++) {
     s += '<option value="' + data.role[i].id + '">' + data.role[i].name + '</option>'; 
    } 
    return s + "</select>"; 
    } 
    } 
    }
    

    it will run fine

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

Sidebar

Related Questions

I am using jqGrid . I am loading the data into the grid from
jqGrid tree nodes are read from server using json data. Click in node reads
I'm trying to load data from the jsp response which is a JSON using
I'm using jQuery Grid 3.7.2 to load data in 'loadonce' mode, i.e. jqGrid takes
I'm using jqGrid to display some data on a page. Within the controller action,
I am using spring MVC 3.0 with the jqgrid plugin. I am building the
I'm currently using jqGrid to display data. Part of jqGrid's interface will give you
I'm trying to return some JSON from my Spring webapp using Jackson and parse
I have a grid with the following definition. Everything is working fine with the
OS: Windows Vista, Framework: Jqgrid (latest), Spring (latest), JQuery (latest) I am using Jqgrid

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.