Announcement

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

    Setting DataSource ID programmatically + related foreign key

    Hi,
    I just started using SmartGWT recently, so these questions might sound stupid. I'm using SmartGWT 2.2.

    I have 2 custom client-side datasources that extend the DataSource class. These datasources use an existing GWT RPC server-side implementation to fetch data.

    There is an AuthorDataSource and a DocumentDataSource. The DocumentDataSource needs to fetch documents that belong to an author selected from the AuthorDataSource through a ListGrid.

    For this purpose I set up a primary key field in the AuthorDataSource, like so:
    Code:
    m_colID = new DataSourceIntegerField("docID", "Doc ID");
    m_colID.setPrimaryKey(true);
    m_colID.setRequired(false);
    m_colID.setHidden(true);
    and a foreign key field in the DocumentDataSource like so:
    Code:
    m_colAuthorID = new DataSourceIntegerField();
    m_colAuthorID.setForeignKey("authorDataSource.docID");
    m_colAuthorID.setHidden(true);
    Currently I call DocumentGrid.fetchRelatedData(...) when a record in the AuthorGrid is clicked.

    And now the questions:
    1) How do I programmatically set the AuthorDataSource's ID for the foreign key to work?
    2) How can I retrieve the record passed to the fetchRelatedData() method in executeFetch() in DocumentDataSource?
    3) Is there a better (or more automatic) approach to this problem (the foreign key looses its purpose if I get the record passed to fetchRelatedData() myself in the executeFetch() method)?

    Thanks in advance for your help!

    #2
    If there are any articles on using fetchRelatedData() together with a custom datasource, I overlooked them. If you have any pointers or links to info about a situation like this, please post them. Thank you.

    Comment

    Working...
    X