I am looking for a bit of additional input and best practice, to give you an overview at the moment I have an application that allows you to create a question and then assign options to that question, be that a drop down, check box, radio button or pretty
much any other standard control.
Each question can have one or more options, now all of that works perfectly. The problem arose when our requirements evolved quite severely, a new question type should now be available, a table with multiple controls per column. That too works without any
Where the major issue arose was with recalling the data of the individual you are dealing with. the moment you work with the multiple rows it did not save a row counter to the table. This was in the design, so I added the field to the table that now keeps
track of value row. The only problem I had is that now when a user removes a random line, and that line not being the last, and he add another line, the line ID gets repeated.
So my problem lies with the design. At the moment the controller generates pure HTML that allows the user to capture everything for the question. It generates a bit of jQuery which allows the ability to add or remove a line [ problematic a tad ] and then
What will be able to do this more elegantly? Knockout? another way about using my views and models, a partial view? I am looking for ideas since I hit a brick wall.
Any advice would be appreciated.
I would like to know the details:
- What the row counter used for?
- What will it affect if the ID is repeated?
- How do you generate the ID? How about the random ID?
Please provide the detail code and snapshot of the design (view)
At the moment I cannot find a place to upload the image to, with it explaining this would go much smoother. It is basically for an online intranet survey. The administrator loads his questions and what the possible options, as well as text boxes. Initially
the application only had to display one question with all the options. It then looked at the database what the administrator captured and built a HTML string which it sent to the view in a ViewBag to then be displayed in Html.Raw, this created the options
dynamically, when the user hits the post button, I capture the FormCollection of the previous view. Then I loop through all the names of the options and start reading the values. After the entire process the response is then just saved.
After a while they decided they want a dynamic table which caters for multiple columns, AND the part I am stuck with now, dynamic multiple rows. So when you click add, it would just populate a line and have all the options still editable.
Now that I started making sure all is well I realized I need a row associated to each options to link it in the answer. Otherwise with no row ID, everything is seen as in the same row, which is not the case.
So at the moment I am just looking for alternative thinking patterns or technologies that might solve this issue.
You’d better provide the detail code and the database schema to me.
For the snapshot, you could upload to the OneDrive and share it with a link, then post the link here.
How about generate the ID in the hidden field for each row?
Thank you for the tip of using OneDrive, I uploaded the image to it, this is what it looks like at the moment http://1drv.ms/1xvggYP, at the moment I have changed it slightly, now the jQuery I generate creates
a variable linked with a row number, it always just gets increased by one after one has been removed, thus there will be no duplicates. The dynamic table build is still fine, the one thing that does happen is that text input boxes repeat the first value for
the amount of rows that is in the client side window.
So now I need to append that row counter after each item name thus being OPTION112.4 for the option with that name on line 4. Or do you have another suggestion how it would work?
PS: I also included a snapshot of what the table looks like that contains the options. http://1drv.ms/1wBQ4yM
Do you try to add random number behind the ID?
You may need provide the detail code.
Well it seems after I rewrote a bit everything is now actually working better than before and faster.
The problem was just the controls had to be grouped by line, and now finally does it. The bug that I had is that some values were repeated and others were ignored. The level of dynamic questions was just something to get used to.
Thank you for the tip though