I am new to Telerik and I am trying to set up a TreeList that binds to an ObjectDataSource, which gets its data from LINQ. The primary LINQ entity is Matter; every matter has an associated Client record.
For the TreeList, Client would be the parent and Matter would be the child.
The problem is, Clients and Matters are in different tables. Can I build out a TreeList programatically like I can a TreeView with nodes? Is there an easier way?
The Client/Matter relationship is defined as an association in LINQ.
---UPDATE---
I've bound ListView to an ObjectDataSource that combines the two tables together. It isn't returning any data, however. Any idea what I am doing wrong? Again, Clients contain Matters. A record will be unique for each Matter but will contain non-unique data for its parent, Client.
<
asp:ObjectDataSource
ID
=
"ClientMattersOds"
runat
=
"server"
OldValuesParameterFormatString
=
"original_{0}"
SelectMethod
=
"GetMattersBilledInPastYear"
TypeName
=
"Data.ClientMatter"
>
<
SelectParameters
>
<
asp:Parameter
Name
=
"emplUno"
Type
=
"Int32"
DefaultValue
=
"66"
/>
</
SelectParameters
>
</
asp:ObjectDataSource
>
<
telerik:RadTreeList
ID
=
"ClientsMattersTreeList"
runat
=
"server"
DataKeyNames
=
"MatterUno"
ParentDataKeyNames
=
"ClientUno"
DataSourceID
=
"ClientMattersOds"
PageSize
=
"25"
OnNeedDataSource
=
"ClientsMattersTreeList_NeedDataSource"
OnDataBound
=
"ClientsMattersTreeList_DataBound"
>
<
ExportSettings
ExportMode
=
"RemoveControls"
>
<
Excel
PageLeftMargin
=
"0.7in"
PageRightMargin
=
"0.7in"
></
Excel
>
<
Pdf
PageWidth
=
"8.5in"
PageHeight
=
"11in"
></
Pdf
>
</
ExportSettings
>
<
EditFormSettings
EditFormType
=
"AutoGenerated"
>
<
EditColumn
MinWidth
=
""
MaxWidth
=
""
></
EditColumn
>
</
EditFormSettings
>
<
Columns
>
<
telerik:TreeListBoundColumn
DataField
=
"CLIENT_UNO"
DataType
=
"System.Int16"
MaxWidth
=
""
MinWidth
=
""
UniqueName
=
"column"
>
</
telerik:TreeListBoundColumn
>
</
Columns
>
</
telerik:RadTreeList
>
[DataObjectMethod(DataObjectMethodType.Select,
true
)]
public
static
List<ClientMatter> GetMattersBilledInPastYear(
int
emplUno)
{
var dc =
new
Data.DdDataContext();
//Get the matters by searching all the time entries for this timekeeper from the past year
//Select only the resulting records that match records from this class
var records = dc.TimeEntries.Where(a => a.TK_EMPL_UNO == emplUno).Select(a =>
new
ClientMatter()
{
_matter_Uno = a.MATTER_UNO,
_client_Uno = a.Matter.CLIENT_UNO,
_matter_Code = a.Matter.MATTER_CODE,
_client_Code = a.Matter.Client.CLIENT_CODE,
_matter_Name = a.Matter.MATTER_NAME,
_client_Name = a.Matter.Client.CLIENT_NAME
}).Distinct().ToList();
return
records;
}