Announcement

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

    Get selected record from datasource

    Hi,

    I like to know how to get the selected record of a datasource. I read how to get it from for examplke a listgrid, but can it also be selected from a datasource?

    I would like to use it for a master - detail application.

    Also can you explain how to use the foreign key property in a datasource. When I have defined one does this then automatically filter detail records when I have selected a record in my master datasource? If no, how can I do this? (see also the first part of my question)

    Bye
    Zoran Sinnema

    #2
    Hi there -

    To your first question: you can call methods on a DataSource to fetch/add/remove/update records. See e.g: http://www.smartclient.com/docs/5.6/...urce.fetchData

    Note that DataSources have no concept of selection, so you can e.g. fetch records matching a particular criteria and then do something with them, but you need a UI component like a ListGrid in order to "select" a record.

    On the second question: you don't need foreignKeys to accomplish master-detail. Here's a simple example that uses the supplyItem and supplyCategory datasources available in the SDK:

    Code:
    isc.TreeGrid.create({
        ID: "categoryTree",
        width: 200,
        height: 400,
        dataSource: "supplyCategory",
        recordClick: "itemList.filterData({category: record.categoryName})"
    });
    categoryTree.fetchData();
    
    isc.TreeGrid.create({
        ID: "itemList",
        width: 400,
        height: 400,
        left: 200,
        dataSource: "supplyItem"
    });
    Basically whenever you click on the record in the TreeGrid, we call filterData() on the ListGrid and pass appropriate filter criteria. In this case, the category.

    There's a live example of this here: http://www.smartclient.com/#showcaseApp

    Take a look at the JS tab for the code. There's a bit of extra code there for pulling in criteria from the form that sits on top of the ListGrid, which you can ignore.

    Comment

    Working...
    X