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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:52:03+00:00 2026-06-05T05:52:03+00:00

I am working on a web application that makes heavy use of grids with

  • 0

I am working on a web application that makes heavy use of grids with select dropdowns for data entry. The grid consists of rows of select boxes. In some situations, there can be hundreds of select boxes on the page at the same time.

At the moment, I render the grid similar to the method below:

function render(jsonData) {
    var html = [];
    $.each(jsonData.Rows, function (i, row) {
        html.push('<tr data-id="', row.Id, '"><td>');
        renderSelect(html, globalVar.ArrayX, row.ValueX);
        html.push('</td><td>');
        renderSelect(html, globalVar.ArrayY, row.ValueY);
        html.push('</td><td>');
        ...
        html.push('</tr>');
    });
    $('tbody#container').html(html.join(''));
}

function renderSelect(html, set, selectedValue) {
    html.push('<select>');
    $.each(set, function (i, item) {
        html.push('<option value="', item.Id, '"', item.Id === selectedValue ? ' selected="1"' : '', '>', item.Name, '</option>');
    });
    html.push('</select>');
}

Most of the select boxes have the same options, only with different selected items per row (so I can’t simply cache the select box html).

Performance is not terrible, Chrome renders the grid in 1 second and FF and IE in about 2. Still I’m wondering, if there may be a more memory/performance efficient alternative to create these select boxes, maybe some way to reference them instead of re-creating them for every row?

  • 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-05T05:52:05+00:00Added an answer on June 5, 2026 at 5:52 am

    Create the select once and use clone to place it where you need it. If the HTML structure is literally the same, all you’d have to do after that is select the appopropriate value for each select

    http://api.jquery.com/clone/

    Your other alternative is to create an html array for the select once before your each statement, join it into a string, and inside the each statement apply it to your the rest of your html picking your the selected option after it’s been added. (I hope that made sense.)

    Either way writing your row and select box before hand, cloning it (or copying the string) for each loop, and selecting the option separately for each, will be your most performant option.

    Here is one possible solution using clone. It doesn’t leverage the performance of manipulating strings over appends, but you can come up with an alternate version for your purposes.

    // construct your html ahead of time
    var rowHtml = [];
    rowHtml.push('<tr"><td>');
    rowHtml.push('<select>');
    $.each(globalVar.ArrayX, function (i, item) {
        rowHtml.push('<option value="', item.Id, '"', '>', item.Name, '</option>');
    });
    rowHtml.push('</select>');
    rowHtml.push('</td><td>');
    $.each(globalVar.ArrayY, function (i, item) {
        rowHtml.push('<option value="', item.Id, '"', '>', item.Name, '</option>');
    });
    rowHtml.push('</select>');
    rowHtml.push('</td><td>');
    rowHtml.push('</tr>');
    var rowTemplate = $(rowHtml.join(''));
    
    // make a variable for the container once so we can save time performing the DOM lookup
    var container = $('tbody#container');
    
    $(jsonData.Rows).each(function (i, row) {
        // since I have to do lookups I've chosen to manipulate attributes using jquery
        // this should move quickly now that we are just cloning
        var clone = rowTemplate.clone();
        clone.attr("data-id", row.Id);
        $("select option[value=" + row.ValueX + "]", clone).attr("selected", "selected");
        container.append(clone);
    });
    

    Another alternative, if you don’t want to do jquery cloning and lookups would be to do string manipulation where you look for the index of the value=”X” statement and insert your selected=selected.

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

Sidebar

Related Questions

I have am working on a web application that makes use of helper classes.
I am working on web application that will use PHP & MySQL. Application will
I'm working on a large website project that makes heavy use of in-page graphing
I'm working on a web application related to genome searching. This application makes use
I'm working on a client-side webapplication that makes heavy use of JavaScript and Ajax
I'm working on an iPhone application that makes a few calls to web services.
I am working on a web application that will make extensive use of AJAX
I'm working on an HTML5-based web application that will make use of a local
I'm working on a web application that submits tasks to a master/worker system that
I'm working on a web application that has a lot to download (javascript, images,

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.