0

Let's say I have the following arrays:

var a = ["Sample A", "Sample B"];
var b = ["X", "Y", "Z"];

Now let's say I have a button that, when clicked, generates the header of a 2D table, like this:

Sample ASample BXYZ

...and another button that adds a new row to the table:

Sample ASample BXYZ
                                      

How would I do the following things:

  • save/restore data from/to the table
  • manage insertions/deletions from any of the arrays that form the header

Notes:

  • the elements of the arrays that form the header can be deleted in any order, but new elements can be appended at the end.
  • ... however, I expect specs to change slightly so that the elements in those arrays can change their position.

EDIT: As suggested by users, I'm adding a plunkr example: http://plnkr.co/edit/FMIgwqKKDbZOCjNTXrrh?p=preview

I know this is flawed and wrong because it's tracking the data by it's index (which is error prone).

7
  • 1
    Have you tried anything yet? Commented Jun 22, 2015 at 19:01
  • Where's your code? Question it too much broad. Commented Jun 22, 2015 at 19:07
  • You're asking to do quite a bit. Is it do-able? Yes absolutely. But with out knowing your app/data/html structure it is insane to try and answer. You should take a stab at trying to do this and post the code so we have something to work off of to help you. All the things you are describing are absolutely do-able. Give it a shot. Commented Jun 22, 2015 at 19:20
  • @ajmajmajma Whaat I'm asking depends directly on the data structure, which I don't know (if I knew I wouldn't be asking). Surely I can place in there an array of arrays, but how would I manage the ordering/deletion/insertion problem? I could do a simple plunkr, but it would be nearly pointless. Commented Jun 22, 2015 at 19:38
  • You should at least attempt it and post it, even if it's not right. You are asking how to do all these things which is basically saying build this for me off of nothing. You have to give stack something to work with. If you know how to build this but don't know how to off an unknown data structure, how is someone else suppose to know? Commented Jun 22, 2015 at 19:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.