This is a migrated thread and some comments may be shown as answers.

[Solved] Need Help With CellTemplateSelector

1 Answer 106 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Joshua
Top achievements
Rank 1
Joshua asked on 04 Sep 2010, 08:37 PM
I'm sure this may be a basic Silverlight question, but I'm needing some help with it.

I've implemented a CellTemplateSelector.  I works fine with "static" information, however here's the scenario I really need...

In the Convert() method, I'll return either two values, let's say "true" or "false" for simplicity.  In order to determine which value to return, I have to do a comparison between two tables - one table is passed as the "value" parameter in the Convert method and I cast it as such.  However, I still need to get the second table.  First, there's no way for me to do a view for this in the SQL database because of the complexity of the system and outside factors. So I'm stuck with a few possible solutions and I don't know how to accomplish any of them. Any help is appreciated.

1) Passing (binding) both datasources to the cell, and extracting both through the value parameter in the Convert method
2) Doing an async lookup inside the IValueConverter.  Here's the current code:

IEnumerable<Web.Purchase> purchases = null;
  
DomainDataSource domainDS = new DomainDataSource();
domainDS.QueryName = "GetPurchasesQuery";
domainDS.DomainContext = new Web.MyAppContext();
domainDS.LoadedData += (s, e) =>
{
    purchases = e.Entities.Cast<Web.Purchase>();
};
domainDS.Load();
  
while (domainDS.IsLoadingData) {}
  
if (purchases.Count() > 0)
    return "View";
else
    return "Purchase";

The problem (I believe) with this, is that the while loop stops the current thread.

3) Return the table and put each one of these cells in a separate thread while showing a busy indicator in the cell and load them each after the inital table load.
 

Thanks,
Joshua

1 Answer, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 09 Sep 2010, 03:07 PM
Hello Joshua,

 The cell's data object is somehow connected with the Purchases set, correct? Your best bet, I think, would be to perform eager loading of the data on the server, and then just query the Purchases property of your data object in SelectTemplate. Please let me know if my guess about your scenario is wrong and I will try to help you reach the best solution. 

Greetings,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Joshua
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Share this question
or