1

I am working in a project where I have following scenario.

I want to create tabulated form at run time. see image below

enter image description here

I want a control like where user can drag and drop, provide number of rows and columns, labels of rows and columns and save it in mysql database.

Later other users will fetch this table from database and fill different column values.

Problem:

What will be the database schema for this dynamic data grid?

Is there any jQuery plugin to create such editable grid?

2 Answers 2

1

As you mention in the comment at Moshe Shaham's answer: "Actually i am creating a template system for surveys". Then:

  1. Make a database table to keeping Survey data.

    servey_id,title, etc.

  2. Make a database table to keeping Question data, linked to the survey_id.

    question_id,survey_id,title,type,order

  3. Make database tables to keeping Answer data, linked to the question_id.

    boolean: answer_id,question_id,value/tinyint(1)

    numeric: answer_id,question_id,value/int(11)

    text: answer_id,question_id,value/varchar(255)

As you see you need multiple tables for Answers, because usually you expecting different data for some questions.

Later you can query and make your tables on-the-fly.

I guess it's the most common way on making such a structure.

Regarding the jQuery part, you can just make the table on-the-fly and then use any kinda libraries or jQuery plug-ins for sorting, formatting, styling, etc.

Sign up to request clarification or add additional context in comments.

4 Comments

thanx for your answer but my question was not related to survey to display in grid. In my survey there are questions and answers as you posted above, but along with questions in my survey there are data grids as I showed you in my question. My question was about grid in survey. Create dynamic grid and save it as part of survey and later show to the users to fill survey.
@IrfanDANISH Can you store the grid as a JSON encoded data in filed in your database? How much data is in there? If you do so, later you can extract it and make it on-the-fly again.
I have to save values against this grid from different users. If i have grid structure as JSON encoded string then how can i save answers of this grid?
@IrfanDANISH Imagine you have an array of column names and another array which contains all the data/rows. Each row is a separated array. You can save the separately or merge them together and then save it as a JSON string.
0

I think the most straightforward solution will be to simply create a new table in the database for each new table the user creates. unless we are talking about a huge number of tables, i think it's simple and easy to work with, since you can let the users select the data type of the column. doing all the custom table in one huge generic table can turn into a mess...

1 Comment

No it will not be feasible, Actually i am creating a template system for surveys. Each survey can have multiple data grids as i showed you in my question. So there are number of templates, and number of tabulated data grids.

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.