views:

39

answers:

1

I'm using a JavaScript component that takes a 2D array as an input. There is a particular format to it, and I basically need to develop grid GUI to help configure such a string, instead of having to type it manually.

[
  [0,"Chart","linear"],
  [2,"3D",false],
  [1,"Labels",["Student","Business","Professional","Retired"]]
]

Any ideas how to build such a thing quickly?

  • Add and remove "rows"
  • Cols have a particular format
+2  A: 

I'm almost certain that Yahoo User Interface (YUI) component exists to do just that. Looks like Datatable might help you.

As an alternative, it should be easy enough to roll your own:

  • A table element

  • A JavaScript method to create a new row piece of DOM

  • An HTML control to add a row (+button), with onClick or somesuch calling the above method

  • A method to loop over all rows in the table and export the data into needed format. [ which format I would strongly suggest to be JSON ]

DVK
Added a link to a component that seems to be usable (full disclosure - I never used DataTable, so i'm basing this only on reviewing the capoabilities listed on YUI site.
DVK
If you need info on the rolling your own part, please be more specific on which items you need help with. Thanks
DVK
Fine, though you seem to be teaching me programming. I wanted more than just a datagrid, something like an MS-Access editor, where cells can be drop-down lists, etc. I thought someone would've created some sort of SDK for such structured-string configuring.
Jenko
Hmm... I'm tempted to reply in the spirit of "Someone did create it - MicroSoft" :).... But I'll restrain myself, since I'm not certain if Access has web interface like most other office apps. :)Also, is it possible that DataTable allows you to have custom input elements in a grid, or you can manually substitute them.
DVK
Actually, my last comment led me to think - may be Google Docs's spreadsheet has components you can import and use in your app? I never used them but if they are Excel replacements like they claim to be, they should allow this functionality.
DVK