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

[Solved] NestedViewTemplate Panel only Appearing in last item in page

5 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peter Maslin
Top achievements
Rank 1
Peter Maslin asked on 14 May 2009, 10:45 AM
hi

i have a grid using the nestedview template , but for some reason the template only displays on the last item on the page , all the others it seems the template doesnt exist , has anyone come across this before ?

Peter.

5 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 18 May 2009, 07:11 AM
Hello Peter,

Can you please post a bit more details as your RadGrid declaration and some code snippets of how grid is populated etc.?

Kind regards,
Rosen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Peter Maslin
Top achievements
Rank 1
answered on 18 May 2009, 07:51 AM
well the main grid is declared using the following function

 

private RadGrid CreateGrid(XmlNode Template,DataSet MainData)

 

{

 

RadGrid RadGrid1 = new RadGrid();

 

RadGrid1.ID =

"RadGrid1";

 

 

RadGrid1.DataSource = MainData;

RadGrid1.DataMember = Template.Attributes[

"Name"].Value;

 

RadGrid1.ShowStatusBar =

true;

 

RadGrid1.AutoGenerateColumns =

false;

 

RadGrid1.AllowSorting =

true;

 

RadGrid1.PageSize = 10;

RadGrid1.PagerStyle.Mode =

GridPagerMode.NextPrevAndNumeric;

 

RadGrid1.AllowMultiRowSelection =

false;

 

RadGrid1.AllowPaging =

true;

 

 

RadGrid1.GridLines =

GridLines.None;

 

RadGrid1.AllowAutomaticUpdates =

true;

 

RadGrid1.AllowAutomaticInserts =

true;

 

RadGrid1.AllowAutomaticDeletes =

true;

 

RadGrid1.Width =

Unit.Percentage(98);

 

RadGrid1.AutoGenerateDeleteColumn =

true;

 

RadGrid1.AutoGenerateEditColumn =

true;

 

 

//RadGrid1.InsertCommand += new GridCommandEventHandler(RadGrid1_InsertCommand);

 

RadGrid1.ItemCommand +=

new GridCommandEventHandler(RadGrid1_ItemCommand);

 

RadGrid1.ItemCreated +=

new GridItemEventHandler(RadGrid1_ItemCreated);

 

 

//RadGrid1.EditCommand += new GridCommandEventHandler(RadGrid1_EditCommand);

 

 

//RadGrid1.NeedDataSource += new GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);

 

 

//RadGrid1.DetailTableDataBind += new GridDetailTableDataBindEventHandler(RadGrid1_DetailTableDataBind);

 

RadGrid1.PreRender +=

new EventHandler(RadGrid1_PreRender);

 

 

RadGrid1.MasterTableView.DataKeyNames =

new string[] { Template.Attributes["GroupLinkID"].Value };

 

RadGrid1.MasterTableView.AllowMultiColumnSorting =

true;

 

RadGrid1.MasterTableView.CommandItemDisplay =

GridCommandItemDisplay.Top;

 

RadGrid1.MasterTableView.Name = Template.Attributes[

"Name"].Value;

 

RadGrid1.MasterTableView.Width =

Unit.Percentage(100);

 

RadGrid1.MasterTableView.GroupLoadMode =

GridGroupLoadMode.Server;

 

 

GridRelationFields LinkFields = new GridRelationFields();

 

LinkFields.DetailKeyField = Template.Attributes[

"GroupLinkID"].Value;

 

LinkFields.MasterKeyField = Template.Attributes[

"GroupLinkID"].Value;

 

RadGrid1.MasterTableView.ParentTableRelation.Add(LinkFields);

 

RadGrid1.MasterTableView.PageSize = 10;

 

return RadGrid1;

 

}

and then a Panel is created with a radtabstrip with a radmultipage control and in each tab is another grid.

the grid is populated using a Fixed Dataset that consists of 3 tables , and the relations between the tables has been defined.

the Nested View Template is added like this

 

MainGrid.MasterTableView.NestedViewTemplate =

new MyTemplate(MyPanel);

 

 

with MyTemplate Defined as 

 

 

class MyTemplate : ITemplate

 

 

 

 

 

{

 

protected Panel MyPanel;

 

 

public MyTemplate(Panel PanelToAdd)

 

{

MyPanel = PanelToAdd;

}

 

public void InstantiateIn(System.Web.UI.Control container)

 

{

container.Controls.Add(MyPanel);

}

}

 

if you need any more information please let me know.

0
Rosen
Telerik team
answered on 21 May 2009, 07:28 AM
Hi Peter,

I suspect that this may be caused by the fact that you are passing same instance of a panel to the nestedViewTemplate. As you may know a control can be placed in only one controlscollection at a time. Therefore you should create a new instance of the panel for each template instead. 

If you continue to experience difficulties please consider sending us (attached to a formal ticket) a small runnable application in which this behavior can be observed.

Best wishes,
Rosen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Peter Maslin
Top achievements
Rank 1
answered on 21 May 2009, 11:11 AM

hi

thanks for that sounds logical , but my only issue is that the nestedviewtemplate is a single instance on the grid and you declare it when you create the grid , how can you declare a new template each time ?

 

0
Rosen
Telerik team
answered on 22 May 2009, 04:32 PM
Hi Peter,

The template will be instantiated for each row  and you should create the panel control its inside InstantiateIn method. If you need to pass some settings to the template in order to correctly create the inner panel you may declare properties or pass values through the constructor.

I hope this information is useful.

Regards,
Rosen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Peter Maslin
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Peter Maslin
Top achievements
Rank 1
Share this question
or