Hi
I am trying to come up with a composite control which includes GridView and Date pager something similar to asp.net grid. I have AllowPagination property. I am finding it difficult as to how link datapager and gridview control in the composite control.
I have seen the sample where it says Datapager Source="{Binding Items, ElementName=radGridView}" but how i can I do the same linking in code behind.
Regards
Kiran
I am trying to come up with a composite control which includes GridView and Date pager something similar to asp.net grid. I have AllowPagination property. I am finding it difficult as to how link datapager and gridview control in the composite control.
I have seen the sample where it says Datapager Source="{Binding Items, ElementName=radGridView}" but how i can I do the same linking in code behind.
Regards
Kiran
5 Answers, 1 is accepted
0
Hi,
pager.SetBinding(RadDataPager.SourceProperty, new Binding("Items") { Source = grid });
Kind regards,
Vlad
the Telerik team
Here is an example:
pager.SetBinding(RadDataPager.SourceProperty, new Binding("Items") { Source = grid });
Vlad
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

Kiran
Top achievements
Rank 1
answered on 11 Oct 2010, 06:18 AM
Hi
Though this works but partially when I add this line of code I can see the datapager is working with but Grid does not show anything do I need to set anything for the grid.
Thanks
Kiran
Though this works but partially when I add this line of code I can see the datapager is working with but Grid does not show anything do I need to set anything for the grid.
DataPager.SetBinding(TngDataPager.SourceProperty,
new
Binding(
"Items"
) { Source = GridView });
Thanks
Kiran
0
Hello,
Vlad
the Telerik team
Can you post how you've set ItemsSource for the grid?
Best wishes,Vlad
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

Kiran
Top achievements
Rank 1
answered on 12 Oct 2010, 09:00 AM
Hi
This is how I am using ItemSource property and Allow Paging property. Things seems to work fine when I run the screen first time but if I try to set the Grid ItemSource again my composite control crashes is there anything I need to do to un-bind and re-bind.
This is how I am trying to set Item Source using code-behind and I get a crash here.
Allow Pagin Property is defined likr this.
Regards
Kiran
This is how I am using ItemSource property and Allow Paging property. Things seems to work fine when I run the screen first time but if I try to set the Grid ItemSource again my composite control crashes is there anything I need to do to un-bind and re-bind.
This is how I am trying to set Item Source using code-behind and I get a crash here.
GridView8.ItemsSource =
TestData.GetDepartments();
#region Property: ItemsSource
/// <summary>
/// Items is the collection of data that is used to generate the content of this control.
/// </summary>
public
Object ItemsSource
{
get
{
return
GetValue(ItemsSourceProperty); }
set
{ SetValue(ItemsSourceProperty, value); }
}
public
static
readonly
DependencyProperty ItemsSourceProperty =
DependencyProperty.Register(
"ItemsSource"
,
typeof
(Object),
typeof
(TngGridView),
new
FrameworkPropertyMetadata
{
PropertyChangedCallback = (obj, e) =>
{
(obj
as
TngGridView).UpdateItemsSource(e.NewValue);
}
});
private
void
UpdateItemsSource(Object sel)
{
GridView.ItemsSource = sel;
}
#endregion
Allow Pagin Property is defined likr this.
#region Property: AllowPaging
private
bool
_allowpaging =
false
;
/// <summary>
/// Sets AllowPaging
/// </summary>
[DesignOnly(
true
)]
public
bool
AllowPaging
{
get
{
return
_allowpaging; }
set
{
_allowpaging = value;
if
(_allowpaging)
{
DataPager.Visibility = Visibility.Visible;
DataPager.SetBinding(TngDataPager.SourceProperty,
new
Binding(
"Items"
) { Source = GridView });
GridView.SetBinding(TngGridView.ItemsSourceProperty,
new
Binding(
"PagedSource"
) { Source = DataPager });
}
}
}
#endregion
Regards
Kiran
0
Accepted
Hello Kiran,
The proper way for things to work would be as follows :
Data goes to Pager.Source
GridView takes ItemsSource from Pager.PagedSource.
When new data comes, you need to change the Pager.Source , not RadGridView.ItemsSource.
And what you do is :
Maybe you need to change the code to update the Pager.Source instead.
In case this does not do the trick , just send me yuor project and I will do the fixes necessary for you .
Sincerely yours,
Pavel Pavlov
the Telerik team
The proper way for things to work would be as follows :
Data goes to Pager.Source
GridView takes ItemsSource from Pager.PagedSource.
When new data comes, you need to change the Pager.Source , not RadGridView.ItemsSource.
And what you do is :
private
void
UpdateItemsSource(Object sel)
{
GridView.ItemsSource = sel;
}
Maybe you need to change the code to update the Pager.Source instead.
In case this does not do the trick , just send me yuor project and I will do the fixes necessary for you .
Sincerely yours,
Pavel Pavlov
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