Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Dynamic Fields (SQL) in Dynamic Form

    Hello,

    I am trying to create a DynamicForm with dynamic fields whose values are stored on a table on the server.
    With other words, I have this table:

    table_positions:
    id name title left top width height
    1 first_name "First Name" 20 20 40 20
    2 last_name "Last Name" 20 40 40 20

    So on the table I save the positions/sizes of all my form fields. (I need that because I will create a lot of different dynamic forms based on the table).

    What is the best way to retrieve the values? Directly using SQL? or is there any way SmartGWT can help me here?

    The way I would do it would be:
    SQL = "select * from table_positions";
    while ( not EOF ) {
    //create field i using metadata in table
    }

    But maybe there is a better way to do that using SmartGWT? What can you recommend me?

    Thanks!

    I am using SmartGWT 2.4 EE.

    #2
    Set up a SQLDataSource pointing to this table, call DataSource.fetchData() on it, and in the callback, create the items. You'll find this is very few lines of code.

    Comment


      #3
      thanks!

      another question: where would the fetch be called?

      I always made a listGrid and showed that grid to the user, and when he scrolls the records the fetch is called. But in this case? The table should not be shown to the user, so what could I do?

      Comment


        #4
        Sorry, not following, You said DynamicForm before, now you've mentioned a grid. What component will receive the dynamic fields and where will it be drawn?

        Comment


          #5
          Thanks for your help, it worked very well!

          Comment

          Working...
          X