• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Arrays in JavaScript

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm wonder to know how to build an array just like the following dynamically. i.e. Im doing a multi columns sorting and from the child window after we selected multiple columns with their order the results should be populated like this.

I was building like this
Here rowCount is number of columns that we selected from the table and resArray is an array.
Is this right way Im building?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rather than using arrays in arrays, I'd make each array element an object with two properties rather than a 2-element array. Makes everything much neater and easier to understand.
 
Madhav Kanneganti
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,

I'm using jquery table sorter api to do multi columns sorting and this api needs the array like this, hence I was requesting how to build dynamically. Would your suggestion applicable to my request?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should have explained that to begin with. If that's what the plugin needs, you can't change it.

What specific problems are you having?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FYI: In HTML4, ids really should not begin with a number. Some browsers have issues with that.

Also the selector $("input:radio[id="+i+"_order]:checked") is a waste. You are making it slower, just select the id!

Personally I would do something more like



>
reply
    Bookmark Topic Watch Topic
  • New Topic