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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:55:16+00:00 2026-05-23T20:55:16+00:00

Good day! I am working on a project right now and I am using

  • 0

Good day!

I am working on a project right now and I am using JQGrid to show my data. As part of its functions, users can choose columns and make these columns as their default columns.

I used ‘columnChooser’ to let my user select for their default columns.

My problem now, how to retrieve those columns the user’s selected?
And how to set those columns as their default columns?

Can someone help me with this problem.

Thanks

Jason

  • 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-23T20:55:16+00:00Added an answer on May 23, 2026 at 8:55 pm

    After the user changes the column layout, you can get the colModel from the grid, iterate through it and push the configuration in a array of json objects which will then be sent to the server. The following code does this:

    function saveColumnConfiguration(grid, url) {
        if (url.length > 0) {
            var colArray = new Array();
            var colModel = grid[0].p.colModel;
            for (var i = 0; i < colModel.length; i++) {
                if (colModel[i].name != "rn" && colModel[i].name != "cb") {
                    colArray.push({
                        Name: colModel[i].name,
                        Width: colModel[i].width,
                        Visible: !colModel[i].hidden
                    });
                }
            }
            $.ajax({
                url: url,
                type: 'POST',
                data: 'columnConfiguration=' + JSON.stringify(colArray)
            });
        }
    }
    

    The check for “rn” and “cb” means don’t take the rownumber and checkbox columns.

    UPDATE

    You will need a class to represent the columns:

    [Serializable]
    public class JqGridColumn
    {
        public string Name { get; set; }
        public int Width { get; set; }
        public bool Visible { get; set; }
    }
    

    You also need custom model binder to deserialize the incoming list:

    public class JqGridConfigurationModelBinder : IModelBinder
    {
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var conf = bindingContext.ValueProvider.GetValue("columnConfiguration").AttemptedValue;
    
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            var configuration = serializer.Deserialize<IEnumerable<JqGridColumn>>(conf);
    
            return configuration;
        }
    }
    

    Register the model binder in application start:

    ModelBinders.Binders.Add(typeof(IEnumerable<JqGridColumn>), new JqGridConfigurationModelBinder());
    

    The action in the controller that handles the list will be something like this:

    public void SaveColumnConfiguration(IEnumerable<JqGridColumn> columnConfiguration)
    {
        // Save the list accordingly...
    }
    

    Note that the order of the columns is represented by their position in the list.
    You can then easily read this configuration and render the grid.

    UPDATE 2

    The function in your case should be called like this

    saveColumnConfiguration($("#freight_bill"), "/Controller/Action");
    

    But not after the call for columnChooser. You can either make another button to save changes when the user chooses to do so or handle the done event from the column chooser like this:

    $("#freight_bill").jqGrid('columnChooser', {
        done: function (perm) {
                if (perm) { 
                    $("#freight_bill").jqGrid("remapColumns", perm, true, false); 
                }
                saveColumnConfiguration($("#freight_bill"), "/Controller/Action");
            }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now a project I'm working on has reached a level of complexity that
Good day people, I am working on a project where i load pages into
Good day, I've been working on this project and learning how to place a
Good day! I'm working on installer, which installs additional dependencies for my software using
Good day everyone. I am working on a Firefox extension, and I want to
Good day everyone, I am building a page in ASP.NET, and using Master Pages
Good day, I am using CacheFilter to filter a certain path to my server
Good day, I receive data from a communication channel and display it. Parallel, I
After working in good ole' c++ all day, I like to have a few
Good day all; I am trying to manually (not using sublayers) draw images within

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.