Go Back   SmartClient Forums > Technical Q&A
Wiki Register Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 29th Aug 2007, 10:37
zsinnema zsinnema is offline
Registered Developer
 
Join Date: Aug 2007
Posts: 7
Default 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
Reply With Quote
  #2  
Old 29th Aug 2007, 11:20
Isomorphic Isomorphic is online now
Administrator
 
Join Date: May 2006
Posts: 30,561
Default

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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search


© 2010,2011 Isomorphic Software. All Rights Reserved