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

[Solved] Dynamical QueryParameters in DomainDataSource

8 Answers 260 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.
Beethoven124
Top achievements
Rank 1
Beethoven124 asked on 17 Aug 2010, 02:28 PM
Hi,

I have a RadGridView on my page to show some records, a HierarchyChildTemplate creation and two DomainDataSources for each grid.

<telerik:RadGridView Margin="6,48,6,167" Name="pakets" ItemsSource="{Binding ElementName=paketSetDomainDataSource, Path=Data}" AutoGenerateColumns="False">
                <telerik:RadGridView.ChildTableDefinitions>
                    <telerik:GridViewTableDefinition>
                        <telerik:GridViewTableDefinition.Relation>
                            <telerik:PropertyRelation ParentPropertyName="Id"/>
                        </telerik:GridViewTableDefinition.Relation>
                    </telerik:GridViewTableDefinition>
                </telerik:RadGridView.ChildTableDefinitions>
 
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Id}" Header="PaketID" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding AbsName}" Header="Absender" />
                </telerik:RadGridView.Columns>
 
                <telerik:RadGridView.HierarchyChildTemplate>
                    <DataTemplate>
                        <telerik:RadGridView Name="stati" ItemsSource="{Binding ElementName=statusSetDomainDataSource, Path=Data}" AutoGenerateColumns="False">
                            <telerik:RadGridView.Columns>
                                <telerik:GridViewDataColumn DataMemberBinding="{Binding Paket_Id}" Header="StatusID" />
                            </telerik:RadGridView.Columns>
                        </telerik:RadGridView>
                    </DataTemplate>
                </telerik:RadGridView.HierarchyChildTemplate>
            </telerik:RadGridView>
 
<riaControls:DomainDataSource PageSize="10" AutoLoad="True" d:DesignData="{d:DesignInstance my1:PaketSet, CreateList=true}" Height="0" LoadedData="paketSetDomainDataSource_LoadedData" Name="paketSetDomainDataSource" QueryName="GetPaketSetsQuery" Width="0">
            <riaControls:DomainDataSource.DomainContext>
                <my:TrackingModelDomainContext />
            </riaControls:DomainDataSource.DomainContext>
        </riaControls:DomainDataSource>
 
        <riaControls:DomainDataSource PageSize="10" AutoLoad="True" d:DesignData="{d:DesignInstance my1:StatusSet, CreateList=true}" Height="0" LoadedData="statusSetDomainDataSource_LoadedData" Name="statusSetDomainDataSource" QueryName="GetStatusSetsQuery" Width="0">
            <riaControls:DomainDataSource.DomainContext>
                <my:TrackingModelDomainContext />
            </riaControls:DomainDataSource.DomainContext>
            <riaControls:DomainDataSource.QueryParameters>
                <riaControls:Parameter ParameterName="id" Value="22" ></riaControls:Parameter>
            </riaControls:DomainDataSource.QueryParameters>
        </riaControls:DomainDataSource>

If I click on the expand icon in front of my record, the second grid will expand with other records, but I have to send them along a dynamic QueryParameter like the ID of my expanded row to, fill my Childgrid with new records via a DomainService.

public class TrackingModelDomainService : LinqToEntitiesDomainService<GoTrackingSystemEntities>
{
 
    // TODO:
    // Consider constraining the results of your query method.  If you need additional input you can
    // add parameters to this method or create additional query methods with different names.
    // To support paging you will need to add ordering to the 'PaketSets' query.
    public IQueryable<PaketSet> GetPaketSets()
    {
        return this.ObjectContext.PaketSets;
    }
 
    // TODO:
    // Consider constraining the results of your query method.  If you need additional input you can
    // add parameters to this method or create additional query methods with different names.
    // To support paging you will need to add ordering to the 'StatusSets' query.
    public IQueryable<StatusSet> GetStatusSets(int id)
    {
        return this.ObjectContext.StatusSets.Where(cell => cell.Paket_Id.Equals(id));
    }
}


So I have only two tables with a 1:n Relationship.
The value of the QueryParameter is "22" and now I need to give the Value the id of the row which I have expanded to fill my childgrid with new records. I can not use javascript.

Is it possible with an other way?

Greetz Beethoven

8 Answers, 1 is accepted

Sort by
0
Beethoven124
Top achievements
Rank 1
answered on 18 Aug 2010, 06:45 AM
no ideas?
0
Accepted
Milan
Telerik team
answered on 18 Aug 2010, 06:54 AM
Hello Beethoven124,

This blog post demonstrates a similar scenario and it might be very helpful. 


All the best,
Milan
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
0
Beethoven124
Top achievements
Rank 1
answered on 18 Aug 2010, 09:35 AM
It works :) very thx a lot. You have saved my day ;).

Greetz Beethoven
0
Beethoven124
Top achievements
Rank 1
answered on 19 Aug 2010, 09:58 AM
I have used the solution from your link in my project and it works fine. But one thing. I always see my expand/toggle cross, the problem is that not each ID of the parentgrid returns records for the childgrid. What can I do? The example with "France" and "Brazil" of the telerik-silverlight-demo doesn´t work for me with the example from Rossen Hristov. And he couldn´t help me.
I hope you can help me.

Thx Beethoven
0
Rossen Hristov
Telerik team
answered on 19 Aug 2010, 10:02 AM
Hello Beethoven124,

My name is Rossen Hristov.

Let me try to explain this. The whole purpose of this client-server technology is to limit the amount of data that resides on the client. If you start reading all data from the server, you might be able to decide whether to hide/show the toggle button but this will defeat the whole purpose of WCF RIA Services.

I hope this makes sense.

Greetings,
Ross
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
0
Beethoven124
Top achievements
Rank 1
answered on 19 Aug 2010, 10:08 AM
Hi,

thx for your answer. I understand it. If i click on the toggle button the query will be execute. I thought there there was an other way. But ok maybe I try it with javascript. Thx again.

Beethoven
0
Kamran Ghane
Top achievements
Rank 1
answered on 12 Nov 2010, 08:05 AM
Ross,

You don't need to read all data from server to support visual help to end user not to have to click on a row to figure out there's no child. It could be annoying when going through a list and interested in rows with children only. One can query only one int per parent row, children count (not all fields of all children records) and provide visual help to end-user.

KG
0
Rossen Hristov
Telerik team
answered on 12 Nov 2010, 10:23 AM
Hi Kamran Ghane,

You can try attaching to the RowLoaded event of the grid. When a row is loaded, go and ask the DomainDataSource about the number of child items based on the parent ID and if it returns zero then find the toggle button and hide it. This might work.

Sincerely yours,
Ross
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
Beethoven124
Top achievements
Rank 1
Answers by
Beethoven124
Top achievements
Rank 1
Milan
Telerik team
Rossen Hristov
Telerik team
Kamran Ghane
Top achievements
Rank 1
Share this question
or