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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:27:31+00:00 2026-05-20T20:27:31+00:00

I am using a custom formatter for a column in jqgrid. Code : function

  • 0

I am using a custom formatter for a column in jqgrid.

Code :

function getCellContentForFormula(cellValue, opts, rowObject) { 
var splitResult = "FHLMC 30 YR";
var selectId = opts.colModel.name + ':' + rowObject.coupon+ ':' + 'substituteSelect';
    //      var $selectBnchmark = $('#productSelect').clone().attr("id",selectId).val(splitResult);
var $selectBnchmark = $('#productSelect').clone().attr("id", selectId);
$('#'+selectId+ ' option[value='+splitResult+']').attr('selected', 'selected');
var bnchMarkSelect = $('<span>').append($selectBnchmark).remove().html();
console.log(bnchMarkSelect);
return '<br/>'+ bnchMarkSelect;
    }

The above code is correctly creating the drop down with the options but is not showing the selected value.

Console.log output:

 <select id="valueOfCMPlusTwo:5:substituteSelect" class="prodSelect"> <option  value="">-Select-</option><option value="FHLMC 15 YR">FHLMC 15 YR</option><option value="FHLMC 30 YR">FHLMC 30 YR</option></select>

I am having trouble combining lines 3 and 4, I need the output like :

<select id="valueOfCMPlusTwo:5:substituteSelect" class="prodSelect"> <option value="">-Select-</option><option value="FHLMC 15 YR">FHLMC 15 YR</option><option value="FHLMC 30 YR" selected="selected">FHLMC 30 YR</option></select>

Please 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-05-20T20:27:32+00:00Added an answer on May 20, 2026 at 8:27 pm

    It you work with the custom formatter you should just work with strings and not use and jQuery operation. For example if you have HTML fragment represented <select> having “blabla” as the “id” and you want to set new id you can just use string replace method. In the same way you can rewrite your custom formatter.

    You current code is much much slowly. You should understand, that every $("#myid") operation is the slower the more elements with id you have on you page. Moreover you use jQuery.clone which has not fixed bugs. So I strictly recommend you simplify the code of your custom formatter and use only string or RegExp operations inside.

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

Sidebar

Related Questions

I am using a custom formatter for my jqGrid columnModel and I can't get
For one of the columns in my jqGrid, I'm providing a custom formatter function.
I'm using jqgrid for which I create column definitions on server as dynamic objects
Background : I am currently using custom controls within my C# project (basic controls
I've been trying to switch from using PerlSetEnv to using custom configuration directives .
I am creating a installer in .NET and using custom actions for controlling installation.
I'm using a custom-built inhouse application that generates a standard set of reports on
I am using some custom controls one of which is a tooltip controller that
We are using a custom FTP application (which encrypts the files) for secure transfers.
I am using a custom item renderer in a combobox to display a custom

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.