Announcement

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

    Related datasources

    Hi,

    I have two data sources: Let's say cars and manufacturers. Now I want to display all cars in one GridList. The database contains an integer value for the manufacturer's ID. But I want to display the name of the manufacturer in my ListGrid, not the integer value.

    In this forum I read about 'OptionDataSource'. As my datasources are defined in xml format, how can I show the manufacturer's name instead of its ID with the least programming effort?
    Is it possible to declare some relation already in the xml Datasource?

    Thank you!
    Chris



    (EDIT: Btw, hopefully, only a short answer is needed: Which type do I have to write in the xml datasource definition to get values for oracle's Timestamp? Right now, I am only getting [object Object]. Thanks for that one, too!)
    Last edited by chrisw; 13 Sep 2010, 06:49.

    #2
    Give that you are using the SQL connector, the most efficient way to do this is shown here and requires a short XML declaration.

    About Oracle's timestamp - what's the fully qualified Java package? Or do you have JavaDoc for it? If it's a subclass of Date like java.sql.Timestamp, it should be handled automatically.

    Comment


      #3
      Thank you for your quick reply!

      I had a look into the sample and it seems to be exactly what I wanted. Just one question on this approach:
      If I have a cars name column and one in Manufacturers, this is not good, right? I haven't identified a possible 'Select manufacturers.name as manuname', so the xml would look like:
      Code:
      <!-- for cars -->
      <field name="name" title="Title" type="text" />
      <!-- for the manufacturer -->
      <field name="name" title="Group" type="text" customSQL="true"  tableName="manufacturers" />
      But then I only get one column for the name field in the ListGrid. With the custom SQL, is it possible to have a 'select as' and thereby rename a field?



      About Oracle's timestamp - What do you mean by package? I have a Oracle database and in that there is a field of type timestamp. I'm not restricted, in principle I could also use Date if that helps. - I just wanna reflect a date-time combo, but I think Oracle's Date type is really only a date without any time information.
      In the xml I tried 'Date' and 'Timestamp' as types. Nothing worked, I get '[object Object]' in the ListGrid's column.

      Comment


        #4
        SmartGWT Server supports a field property called "nativeName" that can be used to fix this problem with column name collisions in multi-table queries - you won't have seen it because it wasn't properly documented, but we've corrected that now and you should see the docs for it in upcoming nightlies. In your specific example, this field declaration ought to be sufficient to fix the name clash:
        Code:
        <field name="manufacturerName" title="Group" type="text" tableName="manufacturer" nativeName="name" />

        Comment


          #5
          Very cool!

          Thank you, that was exactly what I was looking for :-)

          Comment

          Working...
          X