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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:07:26+00:00 2026-06-14T00:07:26+00:00

I am generating column model at server end using C# and passing jSON to

  • 0

I am generating column model at server end using C# and passing jSON to the grid. Now I want one column to give a dropdown functionality. But it is not working out, this is what I have so far:

StringBuilder deptDetails = new StringBuilder();
foreach (Department dept in departmentList)
{
    deptDetails.Append(dept.DepartmentID);
    deptDetails.Append(":'");
    deptDetails.Append(":'" + dept.DepartmentName + "',");
    deptDetails.Append(',');
}
deptDetails.Length -= 1;

colModel[i] = new ColumnMod
{
    name = selectedItems[i].ToString(),
    index = selectedItems[i].ToString(),
    width = 100,
    editable = true,
    edittype = "select",
    align = "left",
    editoptions="{value:{" + deptDetails + "}}"
 };

Here is my columnmodel class:

public class ColumnMod
{
    public string name { get; set; }
    public string index { get; set; }
    //public Boolean key { get; set; }
    public Int32 width { get; set; }
    public Boolean editable { get; set; }
    public string edittype { get; set; }
    //public Boolean sortable { get; set; }
    public string align { get; set; }
    //public Boolean hidden { get; set; }
    public string editoptions { get; set; }
}

EDIT:

Here is my JS code:

$grid.jqGrid({
    colNames: selectedItems,
    colModel: columnSelected,
    sortname: selectedValues[0],
    sortorder: "asc",
    editurl: 'url',
    cellsubmit: 'clientArray',
    cellEdit: true,
    rowNum: 5000,
    rownumbers: true,
    rownumWidth: 30,
    autowidth: true,
    shrinkToFit: true,
    gridview: true,
    pager: '#gridPager',
    viewrecords: true,
    recordtext: "Total Rows: {2}",
    jsonReader: {
        root: "rows",
        page: "page",
        total: "totalpages",
        records: "totalrecords",
        cell: "cell",
        id: selectedValues[0], //index of the column with the PK in it 
        userdata: "userdata",
        repeatitems: true
    },
    prmNames: {
        rows: "numRows",
        page: "page",
        sort: "sortField",
        order: "sortOrder"
    },
    datatype: function (postdata) {
        if (lastSortField != postdata.sortField || lastSortOrder != postdata.sortOrder)
         {   if (!$('#btnValidate').is(':disabled')) {
                lastSortField = postdata.sortField;
                lastSortOrder = postdata.sortOrder;
            }
        }
    }

This is how I get value in columnModel:

function getSelectedColumnsJSON(selectedValues) {
try {
    $.ajax({
        type: "POST",
        url: window.location.protocol + '//' + window.location.host + window.location.pathname + "/getSelectedColumnsJSON",
        data: $.toJSON({
            selectedItems: selectedValues
        }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function (data, status) {
            if (data.d)
                columnSelected = data.d;
        },
        error: function (error) {
            ShowMessage(error.responseText);
        }
    });
}
catch (ex) {
    ShowMessage(ex.message);
}

}

I am getting the dropdown select in the column, but it is empty, I have tried to follow the format that is explained here..any help?

  • 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-14T00:07:27+00:00Added an answer on June 14, 2026 at 12:07 am

    I am not sure that I understand correctly your problem because you don’t posted the JSON data which you use to fill the grid. Do you post DepartmentID or DepartmentName values in the input data? Probably you need to use formatter:’select’ additionally and it will solve your existing problem?

    I don’t understand the full scenario which you need to implement, but It’s typically better to use dataUrl instead of usage of value property of editoptions. Probably the only case when you really have to use value property is the usage of formatter:'select'. Only if the data returned from the server contains ids instead of string data the option dataUrl can’t be used.

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

Sidebar

Related Questions

I'm generating json from a Rails app, and am filtering fields using the format.json
I am having troubles generating a simple database form model. I am using: Doctrine
I'm currently generating Excel-documents using the Office Object Model. I have a problem with
Generating normal columnar data in excel file is quite easy but does any one
Im generating a file to present to the user for download, but the server
The linq to sql designer is not generating the property for one of the
ASP.NET MVC 2 has powerful features for generating the model-dependent content of the Edit
I'm using Hibernate to store a data model, which has a number of simple
Doing Entity Framework (5) code first, although we are not generating our data model
I am using a stored procedure with an EF 4 model. To accomplish this

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.