• 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

Adding and deleting attributes from a javascript object

 
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right now I create my objects manually based on some condition... Something like this...

if (some condition)
columnModel = [{name:'order',index:'order asc', width:70, align:"center"},{name:'job',index:'job',width:300,align:'right'}]

What I want to be able to do is insert or delete from that object. Is there a way to do this? I want to be able to delete the {name:'job',index'job',width:300,align:'right'} piece if a particular condition is met and add others if other conditions are met...

Am I clear? Is this possible?

Thanks
Bryce
 
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
That's not just an object, but an array of objects. Are you talking about removing array entries? You can null them out pretty simply. If you want to manipulate the array further, here's a referecne to array methods. (The splice() method may be what you are looking for).
[ May 19, 2008: Message edited by: Bear Bibeault ]
 
Bryce Martin
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear. I brain farted on this. My coffee didn't work very well this Monday morning (it was a busy weekend with little rest). Thanks for the link. Have a great day.
 
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
Repeat after me: never post before caffeine, never post before caffeine...
 
reply
    Bookmark Topic Watch Topic
  • New Topic