I have been trying to follow the code for loading data into a radgrid using an xml file with hierarchical data with no luck. I have a similar file to the sample invoices / parts code located throughout the telerik codes samples and I can't get "table[0]" to bind with table[2]. The one thing I don't see in any of the samples is the properties that need to be set on the grid after in is placed on a winform (not sure if this is really the problem. Below is the code for my function:
The grid will display table[0] correctly with an arrow indicating the child template but when clicking on the arrow the position indicates the child is open but the data does not display. I have replace table[0] with table[2] as the mastergrid and the data does display as the master data.
Below is a sample of the XML file data
Help!
Doug
private
void
uiTSSearchTitleScan_Click(
object
sender, EventArgs e)
{
DAOLoginService.DAOLoginService LoginServices =
new
DAOLoginService.DAOLoginService();
DAODataService.DAODataService DataServices =
new
DAODataService.DAODataService();
try
{
// create the objects needed for the process
XmlDocument Document =
new
XmlDocument();
XmlNode Result =
null
;
XmlDocument doc =
new
XmlDocument();
XslCompiledTransform xslt =
new
XslCompiledTransform();
DataSet xmlDataSet =
new
DataSet();
//Set Variable Values
string
UserCompany =
"xxxx"
;
string
UserName =
"xxxxx"
;
string
UserPassword =
"xxxx"
;
string
sLotBlkUnit =
"xxx"
;
Result = Document.DocumentElement;
Token = LoginServices.Login(UserCompany, UserName, UserPassword);
Result = DataServices.GetSubdivisionList(Token,
this
.uiCboCounty.SelectedValue.ToString(),
this
.uiTxtSearchFor.Text,
"P"
, sLotBlkUnit,
""
,
""
,
""
,
""
,
""
,
""
);
XmlNode ResultNodes = Document.ImportNode(Result,
true
);
Document.AppendChild(ResultNodes);
//=============================================
// save the original data response from titlescan to xml
//=============================================
Document.Save(
"_GetSubdivisionList.xml"
);
//=============================================
// need to reformat the xml file to friendly tags so
// we do it here
//=============================================
doc.Load(@
"_GetSubdivisionList.xml"
);
xslt.Load(
"GetSubdivisionLotList.xsl"
);
xslt.Transform(
"_GetSubdivisionList.xml"
,
"GetSubdivisionList.xml"
);
xmlDataSet.ReadXml(
"GetSubdivisionList.xml"
);
//=============================================
//clear grid from last lookup if applicable
//=============================================
this
.uiGrdSearchResults.MasterTemplate.Templates.Clear();
this
.uiGrdSearchResults.Relations.Clear();
//=============================================
// setup the grid and load using the xml data provided
//=============================================
GridViewTemplate LotTemplate1 =
new
GridViewTemplate();
this
.uiGrdSearchResults.MasterTemplate.Templates.Add(LotTemplate1);
GridViewRelation relation =
new
GridViewRelation(
this
.uiGrdSearchResults.MasterTemplate);
relation.ChildTemplate = LotTemplate1;
relation.RelationName =
"Subdivisions_LotBlockUnits"
;
relation.ParentColumnNames.Add(
"Subdivision_Id"
);
relation.ChildColumnNames.Add(
"LotBlockUnits_Id"
);
uiGrdSearchResults.Relations.Add(relation);
if
(xmlDataSet.Tables.Count == 0)
{
MessageBox.Show(
"No records found that match the criteria entered."
,
"No Records!"
,MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
}
else
{
this
.uiGrdSearchResults.DataSource = xmlDataSet.Tables[0];
LotTemplate1.DataSource = xmlDataSet.Tables[2];
this
.uiGrdSearchResults.MasterTemplate.BestFitColumns();
this
.uiGrdSearchResults.MasterTemplate.Templates[0].BestFitColumns();
}
}
catch
(Exception ex)
{
if
(Convert.ToString(Token) ==
"00000000-0000-0000-0000-000000000000"
)
{
MessageBox.Show(
"Login Failed. Token returned was \n"
+ Token);
}
else
{
MessageBox.Show(ex.Message);
}
}
finally
{
if
(Convert.ToString(Token) !=
"00000000-0000-0000-0000-000000000000"
)
{
LoginServices.Logout(Token);
}
}
}
The grid will display table[0] correctly with an arrow indicating the child template but when clicking on the arrow the position indicates the child is open but the data does not display. I have replace table[0] with table[2] as the mastergrid and the data does display as the master data.
Below is a sample of the XML file data
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
- <
Subdivisions
>
- <
Subdivision
>
<
CountyCode
>M</
CountyCode
>
<
Name
>CHERRYWOOD VILLAGE CONDO 89-203 POST W/BLKS</
Name
>
<
Number
>CHERRY100</
Number
>
<
DefinitionFlag
>Y</
DefinitionFlag
>
<
UnitFlag
>N</
UnitFlag
>
<
Comments
>UNIT IS LT, BLDG IS BLK EXAMPLE:UNIT 101 BLDG 9500 IS LT 101 BLK 9500 UNIT 9502 BLDG 100 IS LT 950+++</
Comments
>
- <
LotBlockUnits
>
- <
LotBlockUnit
>
<
SubdivisionNumber
>CHERRY100</
SubdivisionNumber
>
<
OpenFlag
>Y</
OpenFlag
>
<
Block
>100</
Block
>
<
StartLot
>9502</
StartLot
>
<
EndLot
/>
<
StartUnit
/>
<
EndUnit
/>
<
StartDate
/>
<
EndDate
/>
<
UnitComments
/>
</
LotBlockUnit
>
- <
LotBlockUnit
>
<
SubdivisionNumber
>CHERRY100</
SubdivisionNumber
>
<
OpenFlag
>Y</
OpenFlag
>
<
Block
>100</
Block
>
<
StartLot
>9504</
StartLot
>
<
EndLot
/>
<
StartUnit
/>
<
EndUnit
/>
<
StartDate
/>
<
EndDate
/>
<
UnitComments
/>
</
LotBlockUnit
>
- <
LotBlockUnit
>
<
SubdivisionNumber
>CHERRY100</
SubdivisionNumber
>
<
OpenFlag
>Y</
OpenFlag
>
<
Block
>100</
Block
>
<
StartLot
>9506</
StartLot
>
<
EndLot
/>
<
StartUnit
/>
<
EndUnit
/>
<
StartDate
/>
<
EndDate
/>
<
UnitComments
/>
</
LotBlockUnit
>
- <
LotBlockUnit
>
<
SubdivisionNumber
>CHERRY100</
SubdivisionNumber
>
<
OpenFlag
>Y</
OpenFlag
>
<
Block
>100</
Block
>
<
StartLot
>9508</
StartLot
>
<
EndLot
/>
<
StartUnit
/>
<
EndUnit
/>
<
StartDate
/>
<
EndDate
/>
<
UnitComments
/>
</
LotBlockUnit
>
- <
LotBlockUnit
>
<
SubdivisionNumber
>CHERRY100</
SubdivisionNumber
>
<
OpenFlag
>Y</
OpenFlag
>
<
Block
>100</
Block
>
<
StartLot
>9510</
StartLot
>
<
EndLot
/>
<
StartUnit
/>
<
EndUnit
/>
<
StartDate
/>
<
EndDate
/>
<
UnitComments
/>
</
LotBlockUnit
>
- <
LotBlockUnit
>
<
SubdivisionNumber
>CHERRY100</
SubdivisionNumber
>
<
OpenFlag
>Y</
OpenFlag
>
<
Block
>100</
Block
>
<
StartLot
>9512</
StartLot
>
<
EndLot
/>
<
StartUnit
/>
<
EndUnit
/>
<
StartDate
/>
<
EndDate
/>
<
UnitComments
/>
</
LotBlockUnit
>
-
</
LotBlockUnits
>
</
Subdivision
>
</
Subdivisions
>
Help!
Doug