Hi
please find the below xaml which i am using and i had attched my grid view how it looks as jpeg(fotter.pjg).
1)All i want is , i need to populate Text box as well as COmbobox in two way mode , please help me urgent?
2) If this is not possible how can i achive what ever i shown in oldapprowaddedstyle.jpg , which i s not footer but they have added a item template row and freezed , how i should achive same in RadGridView.
<
UserControl xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
x:Class="LeMonNext.Client.Modules.SupportAdmin.Views.UserManagementView.UserManagementView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:command="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:LocalGrid="clr-namespace:LeMonNext.Client.Infrastructure.Utility;assembly=LeMonNext.Client.Infrastructure"
mc:Ignorable="d"
d:DesignHeight="700" d:DesignWidth="700" Background="Red">
<UserControl.Resources>
<Style x:Key="CustomGridHeaderStyle" TargetType="telerik:RadGridView">
<Setter Property="AutoGenerateColumns" Value="False"></Setter>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Visible"></Setter>
<Setter Property="ShowColumnFooters" Value="True" ></Setter>
<Setter Property="ShowColumnHeaders" Value="True"></Setter>
<Setter Property="TabNavigation" Value="Cycle"></Setter>
<Setter Property="Height" Value="380"></Setter>
<Setter Property="ShowGroupPanel" Value="False" ></Setter>
<Setter Property="GridLinesVisibility" Value="Both"></Setter>
</Style>
<Style x:Key="CustomGridViewCheckBoxStyle" TargetType="telerik:GridViewCheckBox" >
<Setter Property="HorizontalAlignment" Value="Center"></Setter>
</Style>
<Style x:Key="CustomGridViewFooterStyle" TargetType="telerik:GridViewFooterRow" >
<Setter Property="FontWeight" Value="Bold" ></Setter>
<Setter Property="BorderBrush" Value="Black"></Setter>
<Setter Property="BorderThickness" Value="1"></Setter>
<Setter Property="HorizontalContentAlignment" Value="Left" ></Setter>
</Style>
<DataTemplate x:Key="RoleComboBoxCustomTemplate" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120" />
</Grid.ColumnDefinitions>
<Border Grid.Column="0" >
<TextBlock Text="{Binding RoleName}" HorizontalAlignment="Left" Margin="6,0,0,0" />
</Border>
</Grid>
</DataTemplate>
<Style x:Key="CustomComboBoxStyle"
TargetType="telerik:RadComboBox">
<Setter Property="FontSize"
Value="11"></Setter>
<Setter Property="FontFamily"
Value="Arial"></Setter>
<Setter Property="FontWeight"
Value="Normal"></Setter>
<Setter Property="VerticalAlignment"
Value="Center"></Setter>
<Setter Property="HorizontalAlignment"
Value="Left"></Setter>
<Setter Property="Margin"
Value="2,0,0,0"></Setter>
<Setter Property="Width"
Value="400"></Setter>
</Style>
</UserControl.Resources>
<Grid x:Name="AssignUsersLayoutGridView">
<Grid.Resources>
<LocalGrid:GridRowReadOnlyConvertor x:Key="GridRowReadOnlyConvertor"></LocalGrid:GridRowReadOnlyConvertor>
<LocalGrid:GridOwnerColumnReadOnlyConvertor x:Key="GridOwnerColumnReadOnlyConvertor"></LocalGrid:GridOwnerColumnReadOnlyConvertor>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="600" MinWidth="400" ></ColumnDefinition>
</Grid.ColumnDefinitions>
<!--This the Section For Butoons to fit into the first Row of AssignUsersLayoutGridView-->
<Grid x:Name="HeaderButtonColumn"
HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="0,0,40,500" Grid.RowSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" MinWidth="100"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="57" />
<RowDefinition Height="43" />
</Grid.RowDefinitions>
<telerik:RadButton Grid.Column="4" x:Name="btnSave"
Height="30" BorderBrush="Black" BorderThickness="1"
Content="Save" command:Click.Command="{Binding AddResourceClick}" Margin="0,27,6,0">
</telerik:RadButton>
</Grid>
<!--This the Section For fit the AssignUsersList GridView Control-->
<telerik:RadGridView x:Name="gridResourceAssignment"
Grid.Row="1" Height="500"
ItemsSource="{Binding UsersListItems,Mode=TwoWay}"
Style="{StaticResource CustomGridHeaderStyle}"
SelectedItem="{Binding SelectedItem,UpdateSourceTrigger=Explicit,Mode=TwoWay}"
FooterRowStyle="{StaticResource CustomGridViewFooterStyle}" Margin="40,10,0,0"
SelectionMode="Extended" Width="520">
<Interactivity:Interaction.Behaviors>
<LocalGrid:GridViewMultiSelectBehavior
SelectedItems="{Binding SelectedItems}">
</LocalGrid:GridViewMultiSelectBehavior>
</Interactivity:Interaction.Behaviors>
<telerik:RadGridView.Columns>
<!--COlumn 0-->
<telerik:GridViewDataColumn DataMemberBinding="{Binding UserId,Mode=OneWay}"
HeaderTextAlignment="Center" IsResizable="False"
IsSortable="True" Width="30" TextAlignment="Left"
UniqueName="UserId">
<telerik:GridViewDataColumn.Header>
<StackPanel>
<TextBlock Text="" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" />
</StackPanel>
</telerik:GridViewDataColumn.Header>
<telerik:GridViewDataColumn.Footer>
<TextBox Text="*" Width="40" FontWeight="ExtraBold" FontSize="20" IsReadOnly="True" HorizontalAlignment="Left" TextWrapping="Wrap" />
</telerik:GridViewDataColumn.Footer>
</telerik:GridViewDataColumn>
<!--Column 1-->
<telerik:GridViewDataColumn DataMemberBinding="{Binding UserName}"
HeaderTextAlignment="Center" IsResizable="False"
IsSortable="True" Width="340" TextAlignment="Left"
UniqueName="UserName">
<telerik:GridViewDataColumn.Header>
<StackPanel>
<TextBlock Text="Team Memeber Name" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" />
</StackPanel>
</telerik:GridViewDataColumn.Header>
<telerik:GridViewDataColumn.Footer>
<TextBox Text="{Binding NewTeamMemeberName,Mode=TwoWay}" Width="340" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" />
</telerik:GridViewDataColumn.Footer>
</telerik:GridViewDataColumn>
<!--Column 2-->
<telerik:GridViewComboBoxColumn
UniqueName="Role Name"
SelectedValueMemberPath="RoleId"
DisplayMemberPath="RoleName" IsResizable="False"
DataMemberBinding="{Binding RoleId,Mode=TwoWay}"
ItemTemplate="{StaticResource RoleComboBoxCustomTemplate}"
>
<telerik:GridViewComboBoxColumn.Header>
<StackPanel>
<TextBlock Text="Role Name" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" />
</StackPanel>
</telerik:GridViewComboBoxColumn.Header>
<telerik:GridViewComboBoxColumn.Footer>
<StackPanel>
<telerik:RadComboBox x:Name="UserRoleName" Width="100" Height="25"
SelectedValue="RoleId" SelectedIndex="0"
Style="{StaticResource CustomComboBoxStyle}"
ItemsSource="{Binding NewProjectUsersRoleListItems}"
SelectedValuePath="RoleId"
DisplayMemberPath="RoleName">
</telerik:RadComboBox>
<!-- IsEnabled="{Binding EnaDisNoOfIteration}"
Style="{StaticResource CustomComboBoxStyle}"
SelectedValue="{Binding CurrentUserRoleName,Mode=TwoWay}"
ItemsSource="{Binding IterationNumberList}"
SelectedValuePath="IterationNumber"
DisplayMemberPath="IterationNumber">-->
</StackPanel>
</telerik:GridViewComboBoxColumn.Footer>
</telerik:GridViewComboBoxColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
</
UserControl>
13 Answers, 1 is accepted
You may take a look at our demos demonstrating how to customize the column footers.
Best wishes,Maya
the Telerik team
I have tested the link and it leads to the following example that you can search manually - http://demos.telerik.com/silverlight/#GridView/Totals .
Maya
the Telerik team
Please find the error in demo link which is attached as jpeg. I am working in a bank environment so may be some restriction. Will you please send me some Code snippest which you feel will work FOr adding a text box and combox in rad grid in a toway mode.Sorry yar Finishing task on time is though :). jay telerick
With Thanks,
Fijo Francis .
You may take a look at this article for troubleshooting the error you are getting. Furthermore, the examples in our demos are also available with our controls. So, you may run them locally and see the mentioned example about Totals in RadGridView.
Maya
the Telerik team
One which you talking about is groupfooter my requirement is not to groups some column and show its value in footer ,instaed i need to Use the columns which i defined inside the Fotter as data entery controls. like this.i am on a customer heat.
1)
<
telerik:GridViewComboBoxColumn.Footer>
<StackPanel>
<telerik:RadComboBox x:Name="UserRoleName" Width="100" Height="25"
SelectedValue="RoleId" SelectedIndex="0"
Style="{StaticResource CustomComboBoxStyle}"
ItemsSource="{Binding NewProjectUsersRoleListItems}"
SelectedValuePath="RoleId"
DisplayMemberPath="RoleName">
</telerik:RadComboBox>
<!-- IsEnabled="{Binding EnaDisNoOfIteration}"
Style="{StaticResource CustomComboBoxStyle}"
SelectedValue="{Binding CurrentUserRoleName,Mode=TwoWay}"
ItemsSource="{Binding IterationNumberList}"
SelectedValuePath="IterationNumber"
DisplayMemberPath="IterationNumber">-->
</StackPanel>
</telerik:GridViewComboBoxColumn.Footer>
2)
</telerik:GridViewDataColumn.Footer>
</telerik:GridViewDataColumn>
<!--Column 1-->
<telerik:GridViewDataColumn DataMemberBinding="{Binding UserName}"
HeaderTextAlignment="Center" IsResizable="False"
IsSortable="True" Width="340" TextAlignment="Left"
UniqueName="UserName">
<telerik:GridViewDataColumn.Header>
<StackPanel>
<TextBlock Text="Team Memeber Name" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" />
</StackPanel>
</telerik:GridViewDataColumn.Header>
<telerik:GridViewDataColumn.Footer>
with thanks,
Fijo franicis T
help me urgent , I am stuck at office because of this skipping weekend.
please take this as humble request and help me.
i have tried what you have told me as per demo link you mentioned about.
http://<mymachineip>:<mymachineport>/Default.aspx#GridView/Totals
In this totals they have done footer for Button which is not a data entry iotem like text box or combobox
<telerik:GridViewDataColumn Width="*" Header="Name" DataMemberBinding="{Binding Name}">
<telerik:GridViewDataColumn.AggregateFunctions>
<telerik:MinFunction FunctionName="MinUnitPrice" ResultFormatString="{}{0:c}" SourceField="UnitPrice" />
</telerik:GridViewDataColumn.AggregateFunctions>
<telerik:GridViewDataColumn.Footer>
<telerik:RadButton Content="Show smallest UnitPrice" Click="Button_Click" Margin="5,0" />
</telerik:GridViewDataColumn.Footer>
<telerik:GridViewDataColumn.GroupHeaderTemplate>
<DataTemplate>
<TextBlock Foreground="Green" Text="{Binding Group.Key}" />
</DataTemplate>
</telerik:GridViewDataColumn.GroupHeaderTemplate>
</telerik:GridViewDataColumn>
BUt What i want is how to get this to Text box and cobo box.
I have USer list Which i having username which i need to bind to text box , i have combo box which says users roles ,
How do i get these data controls item binding inside fotter?
My recent changes after reading your demo link project XAML
1) For text box
<telerik:GridViewDataColumn DataMemberBinding="{Binding UserName}"
HeaderTextAlignment="Center" IsResizable="False"
IsSortable="True" Width="340" TextAlignment="Left"
UniqueName="UserName">
<telerik:GridViewDataColumn.Header>
<StackPanel>
<TextBlock Text="Team Memeber Name" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" />
</StackPanel>
</telerik:GridViewDataColumn.Header>
<telerik:GridViewDataColumn.Footer>
<TextBox Text="{Binding NewTeamMemeberName,Mode=TwoWay}" Width="340" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" />
</telerik:GridViewDataColumn.Footer>
<telerik:GridViewDataColumn.GroupHeaderTemplate>
<DataTemplate>
<TextBox Foreground="Green" Text="{Binding UsersListItems.UserName}" />
</DataTemplate>
</telerik:GridViewDataColumn.GroupHeaderTemplate>
</telerik:GridViewDataColumn>
2) FOR Combo
<
telerik:GridViewComboBoxColumn
UniqueName="RoleName"
SelectedValueMemberPath="RoleId"
DisplayMemberPath="RoleName" IsResizable="False"
DataMemberBinding="{Binding RoleId,Mode=TwoWay}"
ItemTemplate="{StaticResource RoleComboBoxCustomTemplate}"
>
<telerik:GridViewComboBoxColumn.Header>
<StackPanel>
<TextBlock Text="Role Name" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" />
</StackPanel>
</telerik:GridViewComboBoxColumn.Header>
<telerik:GridViewComboBoxColumn.Footer>
<telerik:RadComboBox x:Name="UserRoleName" Width="100" Height="25"
SelectedValue="RoleId" SelectedIndex="0"
Style="{StaticResource CustomComboBoxStyle}"
ItemsSource="{Binding NewProjectUsersRoleListItems}"
SelectedValuePath="RoleId"
DisplayMemberPath="RoleName">
</telerik:RadComboBox>
</telerik:GridViewComboBoxColumn.Footer>
<telerik:GridViewComboBoxColumn.GroupHeaderTemplate>
<DataTemplate>
<TextBlock Foreground="Green" Text="{Binding RoleName}" />
</DataTemplate>
</telerik:GridViewComboBoxColumn.GroupHeaderTemplate>
</telerik:GridViewComboBoxColumn>
I and not able to attached the code so puting here
XAML
<
UserControl xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
x:Class="LeMonNext.Client.Modules.SupportAdmin.Views.UserManagementView.UserManagementView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:command="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:LocalGrid="clr-namespace:LeMonNext.Client.Infrastructure.Utility;assembly=LeMonNext.Client.Infrastructure"
mc:Ignorable="d"
d:DesignHeight="700" d:DesignWidth="700" Background="Red">
<UserControl.Resources>
<Style x:Key="CustomGridHeaderStyle" TargetType="telerik:RadGridView">
<Setter Property="AutoGenerateColumns" Value="False"></Setter>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Visible"></Setter>
<Setter Property="ShowColumnFooters" Value="True" ></Setter>
<Setter Property="ShowColumnHeaders" Value="True"></Setter>
<Setter Property="TabNavigation" Value="Cycle"></Setter>
<Setter Property="Height" Value="380"></Setter>
<Setter Property="ShowGroupPanel" Value="False" ></Setter>
<Setter Property="GridLinesVisibility" Value="Both"></Setter>
</Style>
<Style x:Key="CustomGridViewCheckBoxStyle" TargetType="telerik:GridViewCheckBox" >
<Setter Property="HorizontalAlignment" Value="Center"></Setter>
</Style>
<Style x:Key="CustomGridViewFooterStyle" TargetType="telerik:GridViewFooterRow" >
<Setter Property="FontWeight" Value="Bold" ></Setter>
<Setter Property="BorderBrush" Value="Black"></Setter>
<Setter Property="BorderThickness" Value="1"></Setter>
<Setter Property="HorizontalContentAlignment" Value="Left" ></Setter>
</Style>
<DataTemplate x:Key="RoleComboBoxCustomTemplate" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120" />
</Grid.ColumnDefinitions>
<Border Grid.Column="0" >
<TextBlock Text="{Binding RoleName}" HorizontalAlignment="Left" Margin="6,0,0,0" />
</Border>
</Grid>
</DataTemplate>
<Style x:Key="CustomComboBoxStyle"
TargetType="telerik:RadComboBox">
<Setter Property="FontSize"
Value="11"></Setter>
<Setter Property="FontFamily"
Value="Arial"></Setter>
<Setter Property="FontWeight"
Value="Normal"></Setter>
<Setter Property="VerticalAlignment"
Value="Center"></Setter>
<Setter Property="HorizontalAlignment"
Value="Left"></Setter>
<Setter Property="Margin"
Value="2,0,0,0"></Setter>
<Setter Property="Width"
Value="400"></Setter>
</Style>
</UserControl.Resources>
<Grid x:Name="AssignUsersLayoutGridView">
<Grid.Resources>
<LocalGrid:GridRowReadOnlyConvertor x:Key="GridRowReadOnlyConvertor"></LocalGrid:GridRowReadOnlyConvertor>
<LocalGrid:GridOwnerColumnReadOnlyConvertor x:Key="GridOwnerColumnReadOnlyConvertor"></LocalGrid:GridOwnerColumnReadOnlyConvertor>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="600" MinWidth="400" ></ColumnDefinition>
</Grid.ColumnDefinitions>
<!--This the Section For Butoons to fit into the first Row of AssignUsersLayoutGridView-->
<Grid x:Name="HeaderButtonColumn"
HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="0,0,40,500" Grid.RowSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" MinWidth="100"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="57" />
<RowDefinition Height="43" />
</Grid.RowDefinitions>
<telerik:RadButton Grid.Column="4" x:Name="btnSave"
Height="30" BorderBrush="Black" BorderThickness="1"
Content="Save" command:Click.Command="{Binding AddResourceClick}" Margin="0,27,6,0">
</telerik:RadButton>
</Grid>
<!--This the Section For fit the AssignUsersList GridView Control-->
<telerik:RadGridView x:Name="gridResourceAssignment"
Grid.Row="1" Height="500"
ItemsSource="{Binding UsersListItems,Mode=TwoWay}" ShowGroupFooters="True"
Style="{StaticResource CustomGridHeaderStyle}"
SelectedItem="{Binding SelectedItem,UpdateSourceTrigger=Explicit,Mode=TwoWay}"
FooterRowStyle="{StaticResource CustomGridViewFooterStyle}" Margin="40,10,0,0"
SelectionMode="Extended" Width="520">
<Interactivity:Interaction.Behaviors>
<LocalGrid:GridViewMultiSelectBehavior
SelectedItems="{Binding SelectedItems}">
</LocalGrid:GridViewMultiSelectBehavior>
</Interactivity:Interaction.Behaviors>
<telerik:RadGridView.Columns>
<!--COlumn 0-->
<telerik:GridViewDataColumn DataMemberBinding="{Binding UserId,Mode=OneWay}"
HeaderTextAlignment="Center" IsResizable="False"
IsSortable="True" Width="30" TextAlignment="Left"
UniqueName="UserId">
<telerik:GridViewDataColumn.Header>
<StackPanel>
<TextBlock Text="" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" />
</StackPanel>
</telerik:GridViewDataColumn.Header>
<telerik:GridViewDataColumn.Footer>
<TextBox Text="*" Width="40" FontWeight="ExtraBold" FontSize="20" IsReadOnly="True" HorizontalAlignment="Left" TextWrapping="Wrap" />
</telerik:GridViewDataColumn.Footer>
</telerik:GridViewDataColumn>
<!--Column 1-->
<telerik:GridViewDataColumn DataMemberBinding="{Binding UserName}"
HeaderTextAlignment="Center" IsResizable="False"
IsSortable="True" Width="340" TextAlignment="Left"
UniqueName="UserName">
<telerik:GridViewDataColumn.Header>
<StackPanel>
<TextBlock Text="Team Memeber Name" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" />
</StackPanel>
</telerik:GridViewDataColumn.Header>
<telerik:GridViewDataColumn.Footer>
<TextBox Text="{Binding NewTeamMemeberName,Mode=TwoWay}" Width="340" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" />
</telerik:GridViewDataColumn.Footer>
<telerik:GridViewDataColumn.GroupHeaderTemplate>
<DataTemplate>
<TextBox Foreground="Green" Text="{Binding UsersListItems.UserName}" />
</DataTemplate>
</telerik:GridViewDataColumn.GroupHeaderTemplate>
</telerik:GridViewDataColumn>
<!--<telerik:GridViewDataColumn Width="*" Header="Name" DataMemberBinding="{Binding Name}">
<telerik:GridViewDataColumn.AggregateFunctions>
<telerik:MinFunction FunctionName="MinUnitPrice" ResultFormatString="{}{0:c}" SourceField="UnitPrice" />
</telerik:GridViewDataColumn.AggregateFunctions>
<telerik:GridViewDataColumn.Footer>
<telerik:RadButton Content="Show smallest UnitPrice" Click="Button_Click" Margin="5,0" />
</telerik:GridViewDataColumn.Footer>
<telerik:GridViewDataColumn.GroupHeaderTemplate>
<DataTemplate>
<TextBlock Foreground="Green" Text="{Binding Group.Key}" />
</DataTemplate>
</telerik:GridViewDataColumn.GroupHeaderTemplate>
</telerik:GridViewDataColumn>-->
<!--Column 2-->
<telerik:GridViewComboBoxColumn
UniqueName="RoleName"
SelectedValueMemberPath="RoleId"
DisplayMemberPath="RoleName" IsResizable="False"
DataMemberBinding="{Binding RoleId,Mode=TwoWay}"
ItemTemplate="{StaticResource RoleComboBoxCustomTemplate}"
>
<telerik:GridViewComboBoxColumn.Header>
<StackPanel>
<TextBlock Text="Role Name" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" />
</StackPanel>
</telerik:GridViewComboBoxColumn.Header>
<telerik:GridViewComboBoxColumn.Footer>
<telerik:RadComboBox x:Name="UserRoleName" Width="100" Height="25"
SelectedValue="RoleId" SelectedIndex="0"
Style="{StaticResource CustomComboBoxStyle}"
ItemsSource="{Binding NewProjectUsersRoleListItems}"
SelectedValuePath="RoleId"
DisplayMemberPath="RoleName">
</telerik:RadComboBox>
</telerik:GridViewComboBoxColumn.Footer>
<telerik:GridViewComboBoxColumn.GroupHeaderTemplate>
<DataTemplate>
<TextBlock Foreground="Green" Text="{Binding RoleName}" />
</DataTemplate>
</telerik:GridViewComboBoxColumn.GroupHeaderTemplate>
</telerik:GridViewComboBoxColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
</
UserControl>
XAML.cs
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Net;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Documents;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Animation;
using
System.Windows.Shapes;
using
Microsoft.Practices.Unity;
using
Microsoft.Practices.ServiceLocation;
using
Telerik.Windows.Controls.GridView;
using
Telerik.Windows.Controls;
using
LeMonNext.Client.Modules.SupportAdmin.Views.ProjectManagementView;
using
LeMonNext.Client.Modules.SupportAdmin.Views.UserManagementView;
namespace
LeMonNext.Client.Modules.SupportAdmin.Views.UserManagementView
{
/// <summary>
/// Interaction logic for UserManagementView.xaml
/// </summary>
public partial class UserManagementView:UserControl
{
IUnityContainer _container;
public UserManagementView()
{
InitializeComponent();
UserManagementViewModel userManagementViewModel = Container.Resolve<UserManagementViewModel>();
DataContext = userManagementViewModel;
gridResourceAssignment.RowLoaded +=
new EventHandler<RowLoadedEventArgs>(userManagementViewModel.gridViewAssignUsers_RowLoaded);
// gridResourceAssignment.AddingNewDataItem += new EventHandler<GridViewAddingNewEventArgs>(userManagementViewModel.gridViewAssignUsers_AddingNewDataItem);
// gridResourceAssignment.RowEditEnded += new EventHandler<GridViewRowEditEndedEventArgs>(userManagementViewModel.gridViewAssignUserRole_RowEditEnded);
}
private IUnityContainer Container
{
get
{
if (_container == null)
_container =
ServiceLocator.Current.GetInstance<IUnityContainer>();
return _container;
}
}
}
}
XAMLViemodel.cs
using
System;
using
System.Net;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Documents;
using
System.Windows.Ink;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Animation;
using
System.Windows.Shapes;
using
Telerik.Windows.Controls;
using
Microsoft.Practices.Composite.Events;
using
LeMonNext.Client.Infrastructure.Interfaces;
using
LeMonNext.Common.Entities;
using
LeMonNext.Client.Infrastructure.Events;
using
System.Collections.ObjectModel;
using
Microsoft.Practices.Unity;
using
Telerik.Windows.Controls.GridView;
using
LeMonNext.Client.Infrastructure;
using
LeMonNext.Client.Entities;
using
LeMonNext.Client.Infrastructure.Resources;
using
LeMonNext.Client.Infrastructure.Utility;
using
LeMonNext.Client.Modules.SupportAdmin.Services;
using
LeMonNext.Client.Framework.ClientState;
using
LeMonNext.Client.Framework.ViewModel;
using
Microsoft.Practices.Composite.Presentation.Events;
using
System.Collections.Generic;
using
Microsoft.Practices.Composite.Presentation.Commands;
using
System.Reflection;
using
System.Text.RegularExpressions;
using
Microsoft.Practices.Composite.Modularity;
using
Microsoft.Practices.ServiceLocation;
using
LeMonNext.Client.Framework.DependencyService;
namespace
LeMonNext.Client.Modules.SupportAdmin.Views.UserManagementView
{
public class UserManagementViewModel : LeMonViewModelBase
{
#region
Variables
private IEventAggregator _eventAggregator;
private ISupportAdminProjectManagementTabService _IsupportAdminProjectManagementTabService;
private ISupportAdminUserManagementTabService _ISupportAdminUserManagementTabService;
private IClientStateService _iClientStateService;
#endregion
#region
Constructor
public UserManagementViewModel()
{
AddResourceClick =
new DelegateCommand<object>(BtnAddResourceClick);
}
#endregion
Constructor
#region
Dependency Injection
[
Dependency]
public ISupportAdminProjectManagementTabService iSupportAdminProjectManagementTabService
{
get
{
return _IsupportAdminProjectManagementTabService;
}
set
{
_IsupportAdminProjectManagementTabService =
value;
}
}
private Dependency _dependency = new Dependency
{
DependsOnIteration =
false,
DependsOnProject =
false,
ControlID =
Guid.NewGuid().ToString(),
TabName =
RefreshEventParameters.SupportAdmin_UserManagementView
};
[
Dependency]
public IClientStateService iClientStateService
{
get
{
return _iClientStateService;
}
set
{
_iClientStateService =
value;
}
}
[
Dependency]
public IEventAggregator iEventAggregator
{
get
{
return _eventAggregator;
}
set
{
_eventAggregator =
value;
this._eventAggregator.GetEvent<Refresh>().Subscribe(OnRefresh);
}
}
[
Dependency]
public ISupportAdminUserManagementTabService iSupportAdminUserManagementTabService
{
get
{
return _ISupportAdminUserManagementTabService;
}
set
{
_ISupportAdminUserManagementTabService =
value;
this.OnLoadComplete();
}
}
#endregion
#region
BaseClass Override Methods
protected override void SubscribeToEvents()
{
EventAggregator.GetEvent<
Refresh>().Subscribe(OnRefresh);
}
protected override void RegisterDependencyService()
{
DependencyService.RegisterDependency(_dependency);
}
#endregion
BaseClass Override Methods
#region
OnLoadComplete
/// <summary>
/// This Method will fire only first time We load The Page.
/// </summary>
public void OnLoadComplete()
{
_IsupportAdminProjectManagementTabService.GetAllAdminUsers(BindGrid);
BindComboCall();
}
#endregion
OnLoadComplete
#region
OnRefresh
/// <summary>
/// on iteration select or project select event or tab reload event, calling the GetFeaturesTillIteration() method.
/// </summary>
public void OnRefresh(RefreshPayLoad refreshPayLoad)
{
if (DependencyService.NeedsRefresh(refreshPayLoad, _dependency))
{
if (refreshPayLoad.Detail == RefreshEventParameters.SupportAdmin_UserManagementView)
{
if (ApplicationLevelUserList != null)
{
BindGrid(ApplicationLevelUserList);
BindComboCall();
}
}
}
}
#endregion
#region
Methods
#region
Sort :- For alphabetical order
/// <summary>
/// Sort opertion taken from lemon web
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <param name="propertyName"></param>
/// <param name="isIntComparison"></param>
protected static void Sort<T>(IList<T> array, string propertyName, bool isIntComparison)
{
int i, j;
T temp;
if (array != null)
{
for (i = array.Count - 1; i > 0; i--)
{
for (j = 0; j < i; j++)
{
if (isIntComparison == false)
{
string src =
typeof(T).InvokeMember(propertyName, BindingFlags.GetProperty, null, array[j], null) as
string;
string src1 =
typeof(T).InvokeMember(propertyName, BindingFlags.GetProperty, null, array[j + 1], null)
as string;
if (src.CompareTo(src1) > 0)
{
temp = array[j];
array[j] = array[j + 1];
array[j + 1] = temp;
}
}
else
{
string src =
typeof(T).InvokeMember(propertyName, BindingFlags.GetProperty, null, array[j],
null) as string;
string
src1 =
typeof(T).InvokeMember(propertyName, BindingFlags.GetProperty, null, array[j + 1],
null) as string;
if (src != null && src1 != null)
{
if (src.CompareTo(src1) > 0)
{
temp = array[j];
array[j] = array[j + 1];
array[j + 1] = temp;
}
}
}
}
}
}
}
#endregion
Sort :- For alphabetical order
#region
Binding :- Grid
/// <summary>
/// This will set the property for Application UserList
/// </summary>
/// <param name="applicationLevelUserList"></param>
public void BindGrid(IList<Authentication> applicationLevelUserList)
{
ApplicationLevelUserList = applicationLevelUserList;
if (ApplicationLevelUserList != null)
{
RowCount = applicationLevelUserList.Count;
RowCount=RowCount-RowCount;
Sort<
Authentication>(ApplicationLevelUserList, "UserName", false);
foreach (Authentication Au in applicationLevelUserList)
{
RowCount++;
if (Au.UserId != 0)
{
Au.UserId = RowCount;
}
}
UsersListItems = ApplicationLevelUserList;
}
OnPropertyChanged(
"UsersListItems");
}
#endregion
Binding :- Grid
#region
Binding Combo :- Role
/// <summary>
/// This will make general Bind Combo call
/// </summary>
public void BindComboCall()
{
this.iSupportAdminProjectManagementTabService.GetUsersRoles(BindCombo);
}
/// <summary>
/// Binding Combo Items Item Sources.
/// </summary>
/// <param name="ProjectUsersRoles"></param>
public void BindCombo(IList<Authentication> ProjectUsersRoles)
{
ProjectUsersRoleListItem =
new List<UserRole>();
if (ProjectUsersRoles != null)
{
foreach (Authentication authentication in ProjectUsersRoles)
{
CurrentUserRoleName = authentication.RoleName;
// filtering Project Manager Role From value list
if (authentication.RoleId != 3)
{
ProjectUsersRoleListItem.Add(
new UserRole() { RoleId = authentication.RoleId, RoleName = authentication.RoleName });
}
}
}
ProjectUsersRoleListItems = ProjectUsersRoleListItem;
NewProjectUsersRoleListItems = ProjectUsersRoleListItems;
NewTeamMemeberName =
"Firstname.Lastname";
OnPropertyChanged(
"NewTeamMemeberName");
OnPropertyChanged(
"NewProjectUsersRoleListItems");
OnPropertyChanged(
"ProjectUsersRoleListItems");
}
#endregion
Binding Combo :- Role
#region
Binding:-AddResourceClick ClicK
public void BtnAddResourceClick(object obj)
{
NewTeamMemeberName = NewTeamMemeberName;
}
#endregion
Binding:-AddResourceClick ClicK
#endregion
Methods
#region
Radgrid Implemenation
public void gridViewAssignUsers_RowLoaded(object sender, RowLoadedEventArgs e)
{
//GridUpdatedUserList = new List<Authentication>();
if (e.Row is GridViewRow && !(e.Row is GridViewNewRow))
{
RadGridView _radGridView = e.GridViewDataControl as RadGridView;
Authentication _Authentication = e.DataElement as Authentication;
(_radGridView.Columns[
"UserName"] as GridViewDataColumn).IsReadOnly = true;
(_radGridView.Columns[
"UserId"] as GridViewDataColumn).IsReadOnly = true;
(_radGridView.Columns[
"RoleName"] as GridViewComboBoxColumn).ItemsSource = ProjectUsersRoleListItems;
OnPropertyChanged(
"NewTeamMemeberName");
}
}
//public void gridViewAssignUsers_AddingNewDataItem(object sender, GridViewAddingNewEventArgs e)
//{
// e.NewObject = new Task();
// RadGridView _radGridView = e.OwnerGridViewItemsControl as RadGridView;
// _radGridView.TabIndex = 0;
//}
#endregion
Radgrid Implemenation
#region
Properties
#region
Enabling Properties Setting And OnPropertyEvent Firing
/// <summary>
///
/// </summary>
/// <param name="PassedPageObject"></param>
/// <param name="ValueToset"></param>
/// <param name="IsOnpropertyChangeName"></param>
private void PropertySetting(Object PassedPageObject, object ValueToset, string IsOnpropertyChangeName)
{
SetValue(PassedPageObject, ValueToset, IsOnpropertyChangeName);
OnPropertyChanged(IsOnpropertyChangeName);
}
#endregion
Enabling Properties Setting And OoPropertyEvent Firing
#region
Properties Variables
//public IList<Authentication> AuthenticatedResourcesList { get; set; }
//public IList<Authentication> GridUpdatedUserList { get; set; }
public IList<Authentication> UsersListItems { get; set; }
public IList<Authentication> ApplicationLevelUserList { get; set; }
public Project NewCreateAndSelectedProject { get; set; }
public IList<UserRole> ProjectUsersRoleListItem { get; set; }
public IList<UserRole> NewProjectUsersRoleListItems { get; set; }
public static string ControlId { get; set; }
public ObservableCollection<Project> ProjectListItems { get; set; }
public string TeamMemeberName { get; set; }
public string NewTeamMemeberName { get; set; }
private Authentication _selectedItem { get; set; }
public string CurrentUserRoleName { get; set; }
public DelegateCommand<object> AddResourceClick { get; set; }
public bool UserName { get; set; }
public int RowCount { get; set; }
#endregion
Properties Variables
public IList<UserRole> ProjectUsersRoleListItems { get; set; }
#region
property to set Single Selection in grid
//property to set Single Selection in grid
public Authentication SelectedItem
{
get
{
return _selectedItem;
}
set
{
_selectedItem =
value;
OnPropertyChanged(
"SelectedItem");
}
}
#endregion
property to set Single Selection in grid
#region
property to set Multiple Selection in grid
//property to set Multiple Selection in grid
ObservableCollection<Authentication> _selectedItems;
public ObservableCollection<Authentication> SelectedItems
{
get
{
if (_selectedItems == null)
{
_selectedItems =
new ObservableCollection<Authentication>();
}
return _selectedItems;
}
}
#endregion
property to set Multiple Selection in grid
#endregion
Properties
}
}
help me urgent , I am stuck at office because of this skipping weekend.
please take this as humble request and help me.
With thanks,
FIJO Francis T
I am sending you a sample project illustrating how to customize the footer of the corresponding columns. It demonstrates a couple of possible approaches and may use the most appropriate for you.
Maya
the Telerik team
Hi Maya,
PLease help me urgent
//After the Changes you have suggested to get properties from ViewModel i got it like the in the picture "after Change.JPG",Then i removed DataContext="{StaticResource UserManagementViewModel}" from grid layout root and gridview now i am geting grid like this "Final Look But Not able to get values to viewmodel properties.JPG" . still I am not able to set the values back to view model, I have tried binding two way also .
//I am sharing my code here please have a look at my xaml , xaml.cs , View Model .
//Q) Please let me know why I am not able to set back the values to View model.
//Q) I can not add DataContext="{StaticResource UserManagementViewModel}" because I am calling it in XAML .cs file for getting grid row load event binding, SO what is the alternative?
//<UserControl x:Class="LeMonNext.Client.Modules.SupportAdmin.Views.UserManagementView.UserManagementView"
// xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
// xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
// xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
// xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
// xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
// xmlns:command="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
// xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
// xmlns:LocalGrid="clr-namespace:LeMonNext.Client.Infrastructure.Utility;assembly=LeMonNext.Client.Infrastructure"
// mc:Ignorable="d"
// xmlns:my="clr-namespace:LeMonNext.Client.Modules.SupportAdmin.Views.UserManagementView"
// d:DesignHeight="700" d:DesignWidth="700" Background="Red">
// <UserControl.Resources>
// <my:UserManagementViewModel x:Key="UserManagementViewModel"/>
// <Style TargetType="telerik:RadComboBox">
// <Setter Property="MinWidth" Value="100"/>
// </Style>
// <Style x:Key="CustomGridHeaderStyle" TargetType="telerik:RadGridView">
// <Setter Property="AutoGenerateColumns" Value="False"></Setter>
// <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Visible"></Setter>
// <Setter Property="ShowColumnFooters" Value="True" ></Setter>
// <Setter Property="ShowColumnHeaders" Value="True"></Setter>
// <Setter Property="TabNavigation" Value="Cycle"></Setter>
// <Setter Property="Height" Value="380"></Setter>
// <Setter Property="ShowGroupPanel" Value="False" ></Setter>
// <Setter Property="GridLinesVisibility" Value="Both"></Setter>
// </Style>
// <Style x:Key="CustomGridViewCheckBoxStyle" TargetType="telerik:GridViewCheckBox" >
// <Setter Property="HorizontalAlignment" Value="Center"></Setter>
// </Style>
// <Style x:Key="CustomGridViewFooterStyle" TargetType="telerik:GridViewFooterRow" >
// <Setter Property="FontWeight" Value="Bold" ></Setter>
// <Setter Property="BorderBrush" Value="Black"></Setter>
// <Setter Property="BorderThickness" Value="1"></Setter>
// <Setter Property="HorizontalContentAlignment" Value="Left" ></Setter>
// </Style>
// <DataTemplate x:Key="RoleComboBoxCustomTemplate" >
// <Grid>
// <Grid.ColumnDefinitions>
// <ColumnDefinition Width="120" />
// </Grid.ColumnDefinitions>
// <Border Grid.Column="0" >
// <TextBlock Text="{Binding RoleName}" HorizontalAlignment="Left" Margin="6,0,0,0" />
// </Border>
// </Grid>
// </DataTemplate>
// <Style x:Key="CustomComboBoxStyle"
// TargetType="telerik:RadComboBox">
// <Setter Property="FontSize"
// Value="11"></Setter>
// <Setter Property="FontFamily"
// Value="Arial"></Setter>
// <Setter Property="FontWeight"
// Value="Normal"></Setter>
// <Setter Property="VerticalAlignment"
// Value="Center"></Setter>
// <Setter Property="HorizontalAlignment"
// Value="Left"></Setter>
// <Setter Property="Margin"
// Value="2,0,0,0"></Setter>
// <Setter Property="Width"
// Value="400"></Setter>
// </Style>
// </UserControl.Resources>
// <Grid x:Name="AssignUsersLayoutGridView">
// <Grid.Resources>
// <LocalGrid:GridRowReadOnlyConvertor x:Key="GridRowReadOnlyConvertor"></LocalGrid:GridRowReadOnlyConvertor>
// <LocalGrid:GridOwnerColumnReadOnlyConvertor x:Key="GridOwnerColumnReadOnlyConvertor"></LocalGrid:GridOwnerColumnReadOnlyConvertor>
// </Grid.Resources>
// <Grid.RowDefinitions>
// <RowDefinition Height="50"></RowDefinition>
// <RowDefinition Height="*"></RowDefinition>
// </Grid.RowDefinitions>
// <Grid.ColumnDefinitions>
// <ColumnDefinition Width="600" MinWidth="400" ></ColumnDefinition>
// </Grid.ColumnDefinitions>
// <!--This the Section For Butoons to fit into the first Row of AssignUsersLayoutGridView-->
// <Grid x:Name="HeaderButtonColumn"
// HorizontalAlignment="Right"
// VerticalAlignment="Center" Margin="0,0,40,500" Grid.RowSpan="2">
// <Grid.ColumnDefinitions>
// <ColumnDefinition Width="50" MinWidth="100"/>
// </Grid.ColumnDefinitions>
// <Grid.RowDefinitions>
// <RowDefinition Height="57" />
// <RowDefinition Height="43" />
// </Grid.RowDefinitions>
// <telerik:RadButton Grid.Column="4" x:Name="btnSave"
// Height="30" BorderBrush="Black" BorderThickness="1"
// Content="Save" command:Click.Command="{Binding AddResourceClick}" Margin="0,27,6,0">
// </telerik:RadButton>
// </Grid>
// <!--This the Section For fit the AssignUsersList GridView Control-->
// <telerik:RadGridView x:Name="gridResourceAssignment"
// Grid.Row="1" Height="500" DataContext="{StaticResource UserManagementViewModel}"
// ItemsSource="{Binding UsersListItems,Mode=TwoWay}" ShowGroupFooters="True"
// Style="{StaticResource CustomGridHeaderStyle}"
// SelectedItem="{Binding SelectedItem,UpdateSourceTrigger=Explicit,Mode=TwoWay}"
// FooterRowStyle="{StaticResource CustomGridViewFooterStyle}" Margin="40,10,0,0"
// SelectionMode="Extended" Width="520">
// <Interactivity:Interaction.Behaviors>
// <LocalGrid:GridViewMultiSelectBehavior
// SelectedItems="{Binding SelectedItems}">
// </LocalGrid:GridViewMultiSelectBehavior>
// </Interactivity:Interaction.Behaviors>
// <telerik:RadGridView.Columns>
// <!--COlumn 0-->
// <telerik:GridViewDataColumn DataMemberBinding="{Binding UserId,Mode=OneWay}"
// HeaderTextAlignment="Center" IsResizable="False"
// IsSortable="True" Width="30" TextAlignment="Left"
// UniqueName="UserId">
// <telerik:GridViewDataColumn.Header>
// <StackPanel>
// <TextBlock Text="" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" />
// </StackPanel>
// </telerik:GridViewDataColumn.Header>
// <telerik:GridViewDataColumn.Footer>
// <TextBox Text="*" Width="40" FontWeight="ExtraBold" FontSize="20" IsReadOnly="True" HorizontalAlignment="Left" TextWrapping="Wrap" />
// </telerik:GridViewDataColumn.Footer>
// </telerik:GridViewDataColumn>
// <!--Column 1-->
// <telerik:GridViewDataColumn DataMemberBinding="{Binding UserName}"
// HeaderTextAlignment="Center" IsResizable="False"
// IsSortable="True" Width="306" TextAlignment="Left"
// UniqueName="UserName">
// <telerik:GridViewDataColumn.Header>
// <StackPanel>
// <TextBlock Text="Team Memeber Name" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" />
// </StackPanel>
// </telerik:GridViewDataColumn.Header>
// <telerik:GridViewDataColumn.Footer>
// <TextBox Text="{Binding NewTeamMemeberName,Source={StaticResource UserManagementViewModel}}"
// Width="306" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" />
// </telerik:GridViewDataColumn.Footer>
// </telerik:GridViewDataColumn>
// <!--Column 2-->
// <telerik:GridViewComboBoxColumn
// UniqueName="RoleName"
// SelectedValueMemberPath="RoleId"
// DisplayMemberPath="RoleName" IsResizable="False"
// DataMemberBinding="{Binding RoleId,Mode=TwoWay}"
// ItemTemplate="{StaticResource RoleComboBoxCustomTemplate}">
// <telerik:GridViewComboBoxColumn.Header>
// <StackPanel>
// <TextBlock Text="Role Name" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" />
// </StackPanel>
// </telerik:GridViewComboBoxColumn.Header>
// <telerik:GridViewComboBoxColumn.FooterCellStyle>
// <Style TargetType="telerik:GridViewFooterCell">
// <Setter Property="Template">
// <Setter.Value>
// <ControlTemplate>
// <telerik:RadComboBox
// SelectedValuePath="{Binding CurrentFotterUserRoleName,Source={StaticResource UserManagementViewModel}}"
// ItemsSource="{Binding MyUserRoles,
// Source={StaticResource UserManagementViewModel}}"/>
// </ControlTemplate>
// </Setter.Value>
// </Setter>
// </Style>
// </telerik:GridViewComboBoxColumn.FooterCellStyle>
// </telerik:GridViewComboBoxColumn>
// </telerik:RadGridView.Columns>
// </telerik:RadGridView>
// </Grid>
//</UserControl>
// XAML>CS
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Net;
//using System.Windows;
//using System.Windows.Controls;
//using System.Windows.Documents;
//using System.Windows.Input;
//using System.Windows.Media;
//using System.Windows.Media.Animation;
//using System.Windows.Shapes;
//using Microsoft.Practices.Unity;
//using Microsoft.Practices.ServiceLocation;
//using Telerik.Windows.Controls.GridView;
//using Telerik.Windows.Controls;
//using LeMonNext.Client.Modules.SupportAdmin.Views.ProjectManagementView;
//namespace LeMonNext.Client.Modules.SupportAdmin.Views.UserManagementView
//{
///// <summary>
///// Interaction logic for UserManagementView.xaml
///// </summary>
//public partial class UserManagementView:UserControl
//{
//IUnityContainer _container;
//public UserManagementView()
//{
//InitializeComponent();
//UserManagementViewModel userManagementViewModel = Container.Resolve<UserManagementViewModel>();
//DataContext = userManagementViewModel;
//gridResourceAssignment.RowLoaded += new EventHandler<RowLoadedEventArgs>(userManagementViewModel.gridViewAssignUsers_RowLoaded);
//}
//private IUnityContainer Container
//{
//get
//{
//if (_container == null)
//_container = ServiceLocator.Current.GetInstance<IUnityContainer>();
//return _container;
//}
//}
//}
//}
// View Model
//using System;
//using System.Net;
//using System.Windows;
//using System.Windows.Controls;
//using System.Windows.Documents;
//using System.Windows.Ink;
//using System.Windows.Input;
//using System.Windows.Media;
//using System.Windows.Media.Animation;
//using System.Windows.Shapes;
//using Telerik.Windows.Controls;
//using Microsoft.Practices.Composite.Events;
//using LeMonNext.Client.Infrastructure.Interfaces;
//using LeMonNext.Common.Entities;
//using LeMonNext.Client.Infrastructure.Events;
//using System.Collections.ObjectModel;
//using Microsoft.Practices.Unity;
//using Telerik.Windows.Controls.GridView;
//using LeMonNext.Client.Infrastructure;
//using LeMonNext.Client.Entities;
//using LeMonNext.Client.Infrastructure.Resources;
//using LeMonNext.Client.Infrastructure.Utility;
//using LeMonNext.Client.Modules.SupportAdmin.Services;
//using LeMonNext.Client.Framework.ClientState;
//using LeMonNext.Client.Framework.ViewModel;
//using Microsoft.Practices.Composite.Presentation.Events;
//using System.Collections.Generic;
//using Microsoft.Practices.Composite.Presentation.Commands;
//using System.Reflection;
//using System.Text.RegularExpressions;
//using Microsoft.Practices.Composite.Modularity;
//using Microsoft.Practices.ServiceLocation;
//using LeMonNext.Client.Framework.DependencyService;
//using System.ComponentModel;
//namespace LeMonNext.Client.Modules.SupportAdmin.Views.UserManagementView
//{
//public class UserManagementViewModel : LeMonViewModelBase
//{
//#region Variables
//private IEventAggregator _eventAggregator;
//private ISupportAdminProjectManagementTabService _IsupportAdminProjectManagementTabService;
//private ISupportAdminUserManagementTabService _ISupportAdminUserManagementTabService;
//private IClientStateService _iClientStateService;
//#endregion
//#region Constructor
//public UserManagementViewModel()
//{
//AddResourceClick = new DelegateCommand<object>(BtnAddResourceClick);
//}
//#endregion Constructor
//#region Dependency Injection
//[Dependency]
//public ISupportAdminProjectManagementTabService iSupportAdminProjectManagementTabService
//{
//get
//{
//return _IsupportAdminProjectManagementTabService;
//}
//set
//{
//_IsupportAdminProjectManagementTabService = value;
//}
//}
//private Dependency _dependency = new Dependency
//{
//DependsOnIteration = false,
//DependsOnProject = false,
//ControlID = Guid.NewGuid().ToString(),
//TabName = RefreshEventParameters.SupportAdmin_UserManagementView
//};
//[Dependency]
//public IClientStateService iClientStateService
//{
//get
//{
//return _iClientStateService;
//}
//set
//{
//_iClientStateService = value;
//}
//}
//[Dependency]
//public IEventAggregator iEventAggregator
//{
//get
//{
//return _eventAggregator;
//}
//set
//{
//_eventAggregator = value;
//this._eventAggregator.GetEvent<Refresh>().Subscribe(OnRefresh);
//}
//}
//[Dependency]
//public ISupportAdminUserManagementTabService iSupportAdminUserManagementTabService
//{
//get
//{
//return _ISupportAdminUserManagementTabService;
//}
//set
//{
//_ISupportAdminUserManagementTabService = value;
//this.OnLoadComplete();
//}
//}
//#endregion
//#region BaseClass Override Methods
//protected override void SubscribeToEvents()
//{
//EventAggregator.GetEvent<Refresh>().Subscribe(OnRefresh);
//}
//protected override void RegisterDependencyService()
//{
//DependencyService.RegisterDependency(_dependency);
//}
//#endregion BaseClass Override Methods
//#region OnLoadComplete
///// <summary>
///// This Method will fire only first time We load The Page.
///// </summary>
//public void OnLoadComplete()
//{
//_IsupportAdminProjectManagementTabService.GetAllAdminUsers(BindGrid);
//BindComboCall();
//}
//#endregion OnLoadComplete
//#region OnRefresh
///// <summary>
///// on iteration select or project select event or tab reload event, calling the GetFeaturesTillIteration() method.
///// </summary>
//public void OnRefresh(RefreshPayLoad refreshPayLoad)
//{
//if (DependencyService.NeedsRefresh(refreshPayLoad, _dependency))
//{
//if (refreshPayLoad.Detail == RefreshEventParameters.SupportAdmin_UserManagementView)
//{
//if (ApplicationLevelUserList != null)
//{
//BindGrid(ApplicationLevelUserList);
//BindComboCall();
//}
//}
//}
//}
//#endregion
//#region Methods
//#region Sort :- For alphabetical order
///// <summary>
///// Sort opertion taken from lemon web
///// </summary>
///// <typeparam name="T"></typeparam>
///// <param name="array"></param>
///// <param name="propertyName"></param>
///// <param name="isIntComparison"></param>
//protected static void Sort<T>(IList<T> array, string propertyName, bool isIntComparison)
//{
//int i, j;
//T temp;
//if (array != null)
//{
//for (i = array.Count - 1; i > 0; i--)
//{
//for (j = 0; j < i; j++)
//{
//if (isIntComparison == false)
//{
//string src =
//typeof(T).InvokeMember(propertyName, BindingFlags.GetProperty, null, array[j], null) as
//string;
//string src1 =
//typeof(T).InvokeMember(propertyName, BindingFlags.GetProperty, null, array[j + 1], null)
//as string;
//if (src.CompareTo(src1) > 0)
//{
//temp = array[j];
//array[j] = array[j + 1];
//array[j + 1] = temp;
//}
//}
//else
//{
//string src =
//typeof(T).InvokeMember(propertyName, BindingFlags.GetProperty, null, array[j],
//null) as string;
//string
//src1 =
//typeof(T).InvokeMember(propertyName, BindingFlags.GetProperty, null, array[j + 1],
//null) as string;
//if (src != null && src1 != null)
//{
//if (src.CompareTo(src1) > 0)
//{
//temp = array[j];
//array[j] = array[j + 1];
//array[j + 1] = temp;
//}
//}
//}
//}
//}
//}
//}
//#endregion Sort :- For alphabetical order
//#region Binding :- Grid
///// <summary>
///// This will set the property for Application UserList
///// </summary>
///// <param name="applicationLevelUserList"></param>
//public void BindGrid(IList<Authentication> applicationLevelUserList)
//{
//ApplicationLevelUserList = applicationLevelUserList;
//if (ApplicationLevelUserList != null)
//{
//RowCount = applicationLevelUserList.Count;
//RowCount=RowCount-RowCount;
//Sort<Authentication>(ApplicationLevelUserList, "UserName", false);
//foreach (Authentication Au in applicationLevelUserList)
//{
//RowCount++;
//if (Au.UserId != 0)
//{
//Au.UserId = RowCount;
//}
//}
//UsersListItems = ApplicationLevelUserList;
//}
//}
//#endregion Binding :- Grid
//#region Binding Combo :- Role
///// <summary>
///// This will make general Bind Combo call
///// </summary>
//public void BindComboCall()
//{
//this.iSupportAdminProjectManagementTabService.GetUsersRoles(BindCombo);
//}
///// <summary>
///// Binding Combo Items Item Sources.
///// </summary>
///// <param name="ProjectUsersRoles"></param>
//public void BindCombo(IList<Authentication> ProjectUsersRoles)
//{
////Static fotter binding
////dynamic Column Binding
//projectUsersRoleListItems = new List<UserRole>();
//if (ProjectUsersRoles != null)
//{
//foreach (Authentication authentication in ProjectUsersRoles)
//{
//CurrentUserRoleName = authentication.RoleName;
//// filtering Project Manager Role From value list
//if (authentication.RoleId != 3)
//{
//projectUsersRoleListItems.Add(new UserRole() { RoleId = authentication.RoleId, RoleName = authentication.RoleName });
//}
//}
//}
//ProjectUsersRoleListItems = projectUsersRoleListItems;
//}
//#endregion Binding Combo :- Role
//#region Binding:-AddResourceClick ClicK
//public void BtnAddResourceClick(object obj)
//{
//NewTeamMemeberName = NewTeamMemeberName;
//CurrentUserRoleName =CurrentFotterUserRoleName;
//}
//#endregion Binding:-AddResourceClick ClicK
//#endregion Methods
//#region Radgrid Implemenation
//public void gridViewAssignUsers_RowLoaded(object sender, RowLoadedEventArgs e)
//{
////GridUpdatedUserList = new List<Authentication>();
//if (e.Row is GridViewRow && !(e.Row is GridViewNewRow))
//{
//RadGridView _radGridView = e.GridViewDataControl as RadGridView;
//Authentication _Authentication = e.DataElement as Authentication;
//(_radGridView.Columns["UserName"] as GridViewDataColumn).IsReadOnly = true;
//(_radGridView.Columns["UserId"] as GridViewDataColumn).IsReadOnly = true;
//(_radGridView.Columns["RoleName"] as GridViewComboBoxColumn).ItemsSource = ProjectUsersRoleListItems;
//}
//}
//#endregion Radgrid Implemenation
//#region Properties
//#region Enabling Properties Setting And OnPropertyEvent Firing
///// <summary>
/////
///// </summary>
///// <param name="PassedPageObject"></param>
///// <param name="ValueToset"></param>
///// <param name="IsOnpropertyChangeName"></param>
//private void PropertySetting(Object PassedPageObject, object ValueToset, string IsOnpropertyChangeName)
//{
//SetValue(PassedPageObject, ValueToset, IsOnpropertyChangeName);
//OnPropertyChanged(IsOnpropertyChangeName);
//}
//#endregion Enabling Properties Setting And OoPropertyEvent Firing
//#region Properties Variables
//#region Binding The Grid With UserList
//private IList<Authentication> usersListItems { get; set; }
//public IList<Authentication> UsersListItems
//{
//get
//{
//return usersListItems;
//}
//set
//{
//if (value != this.usersListItems)
//{
//this.usersListItems = value;
//this.OnPropertyChanged("UsersListItems");
//}
//}
//}
//#endregion Binding The Grid With UserList
//#region User Role list population For Coluimn Binding
//private IList<UserRole> projectUsersRoleListItems { get; set; }
//public IList<UserRole> ProjectUsersRoleListItems
//{
//get
//{
//return projectUsersRoleListItems;
//}
//set
//{
//if (value != this.projectUsersRoleListItems)
//{
//this.projectUsersRoleListItems = value;
//this.OnPropertyChanged("ProjectUsersRoleListItems");
//}
//}
//}
//#endregion User Role list population For Coluimn Binding
//#region User Role list population For Footer Binding
//private ObservableCollection<string> myUserRoles;
//public ObservableCollection<string> MyUserRoles
//{
//get
//{
//if (this.myUserRoles == null)
//{
//this.myUserRoles = new ObservableCollection<string>() { "User", "Admin", "Super User", "Support" };
//}
//return this.myUserRoles;
//}
//set
//{
//myUserRoles = value;
//}
//}
//private string currentUserRoleNameFotter { get; set; }
//public string CurrentFotterUserRoleName
//{
//get
//{
//return currentUserRoleNameFotter;
//}
//set
//{
//if (value != this.currentUserRoleNameFotter)
//{
//this.currentUserRoleNameFotter = value;
//}
//}
//}
//#endregion User Role list population For Footer Binding
//#region Footer TeammembernNameSettings
//private string newTeamMemeberName;
//public string NewTeamMemeberName
//{
//get
//{
//return newTeamMemeberName;
//}
//set
//{
//if (value != this.newTeamMemeberName)
//{
//this.newTeamMemeberName = value;
//this.OnPropertyChanged("NewTeamMemeberName");
//}
//}
//}
//#endregion Footer TeammembernNameSettings
//#region property to set Single Selection in grid
////property to set Single Selection in grid
//public Authentication SelectedItem
//{
//get
//{
//return _selectedItem;
//}
//set
//{
//_selectedItem = value;
//this.OnPropertyChanged("SelectedItem");
//}
//}
//#endregion property to set Single Selection in grid
//#region property to set Multiple Selection in grid
////property to set Multiple Selection in grid
//ObservableCollection<Authentication> _selectedItems;
//public ObservableCollection<Authentication> SelectedItems
//{
//get
//{
//if (_selectedItems == null)
//{
//_selectedItems = new ObservableCollection<Authentication>();
//}
//return _selectedItems;
//}
//}
//#endregion property to set Multiple Selection in grid
//public IList<Authentication> ApplicationLevelUserList { get; set; }
//public Project NewCreateAndSelectedProject { get; set; }
//public static string ControlId { get; set; }
//public ObservableCollection<Project> ProjectListItems { get; set; }
//public string TeamMemeberName { get; set; }
//private Authentication _selectedItem { get; set; }
//public string CurrentUserRoleName { get; set; }
//public DelegateCommand<object> AddResourceClick { get; set; }
//public bool UserName { get; set; }
//public int RowCount { get; set; }
//#endregion Properties Variables
//#endregion Properties
//}
//}
//With Thanks,
//Fijo Francis T
Hi Maya,
Thank for showing property settings .But my Client requirement is I have grid like this as I shown in figure
“MyGridFooter1.JPG”.
There might be frequent requirement of adding user to this grid so as of now we are adding the user in First row of the rad grid using normal red grid ADDITEM Method. But I cannot use this that’s why I asked how can I set and get the values from footer so that user need not scroll up and down to add new user instead he can add at footer. Like I tried in “MyGridFooter1.JPG”. I thought a save button delegation will help me to send the already set values in footer to save button delegation. But I have briefly explained current behavior down.
Behavior Of property setting (this steps are same for text box and drop down so when you reply if there is any change I need to do for combo box please tell me)
Step 1:-
When you type your user name as a desired form and in text lost focus it will call the property settings and set the value as you can see in the figure “MyGridFooter2.JPG”. Here Duplicate variable set the value I typed in Grid footer. Good (:-:),
Step 2:-
Please have look at “MyGridFooter3.JPG”, “MyGridFooter4.JPG”, “MyGridFooter5.JPG”
Step 3:-
When I press save button you will see the public property Duplicate is null. Please have look at
“MyGridFooter6.JPG”
Step 4:-
Please have look at these pictures also “Grid footer RAD PART.JPG “,”MyGridFooterRadPArt.JPG”
Q1)“Will you please tell me What I should do to get in save delegate click?”
Here is view model properties
#region Properties
#region Enabling Properties Setting And OnPropertyEvent Firing
/// <summary>
///
/// </summary>
/// <param name="PassedPageObject"></param>
/// <param name="ValueToset"></param>
/// <param name="IsOnpropertyChangeName"></param>
private void PropertySetting(Object PassedPageObject, object ValueToset, string IsOnpropertyChangeName)
{
SetValue(PassedPageObject, ValueToset, IsOnpropertyChangeName);
OnPropertyChanged(IsOnpropertyChangeName);
}
#endregion Enabling Properties Setting And OoPropertyEvent Firing
#region Properties Variables
#region Binding The Grid With UserList
private IList<Authentication> usersListItems { get; set; }
public IList<Authentication> UsersListItems
{
get
{
return usersListItems;
}
set
{
if (value != this.usersListItems)
{
this.usersListItems = value;
this.OnPropertyChanged("UsersListItems");
}
}
}
#endregion Binding The Grid With UserList
#region User Role list population For Coluimn Binding
private IList<UserRole> projectUsersRoleListItems { get; set; }
public IList<UserRole> ProjectUsersRoleListItems
{
get
{
return projectUsersRoleListItems;
}
set
{
if (value != this.projectUsersRoleListItems)
{
this.projectUsersRoleListItems = value;
this.OnPropertyChanged("ProjectUsersRoleListItems");
}
}
}
#endregion User Role list population For Coluimn Binding
#region User Role list population For Footer Binding
private ObservableCollection<string> myUserRoles;
public ObservableCollection<string> MyUserRoles
{
get
{
if (this.myUserRoles == null)
{
this.myUserRoles = new ObservableCollection<string>() { "User", "Admin", "Super User", "Support" };
}
return this.myUserRoles;
}
set
{
myUserRoles = value;
}
}
private string currentUserRoleNameFotter { get; set; }
public string CurrentFotterUserRoleName
{
get
{
return currentUserRoleNameFotter;
}
set
{
if (value != this.currentUserRoleNameFotter)
{
this.currentUserRoleNameFotter = value;
}
}
}
#endregion User Role list population For Footer Binding
#region Footer TeammembernNameSettings
private string userName = "FirstName.LastName";
public string UserName
{
get
{
return userName;
}
set
{
if (value != this.userName)
{
Duplicate = value;
}
}
}
#endregion Footer TeammembernNameSettings
#region property to set Single Selection in grid
//property to set Single Selection in grid
public Authentication SelectedItem
{
get
{
return _selectedItem;
}
set
{
_selectedItem = value;
this.OnPropertyChanged("SelectedItem");
}
}
#endregion property to set Single Selection in grid
#region property to set Multiple Selection in grid
//property to set Multiple Selection in grid
ObservableCollection<Authentication> _selectedItems;
public ObservableCollection<Authentication> SelectedItems
{
get
{
if (_selectedItems == null)
{
_selectedItems = new ObservableCollection<Authentication>();
}
return _selectedItems;
}
}
#region Binding:-AddResourceClick ClicK
public void BtnAddResourceClick(object obj)
{
string CurrentUserRoleName = Duplicate;
}
#endregion Binding:-AddResourceClick ClicK
#endregion property to set Multiple Selection in grid
public ObservableCollection<Authentication> ApplicationLevelUserList { get; set; }
public ObservableCollection<Authentication> _editedAuthenticationList { get; set; }
public ObservableCollection<Authentication> _NewEditedAuthenticationList { get; set; }
public string Duplicate { get; set; }
public Project NewCreateAndSelectedProject { get; set; }
public static string ControlId { get; set; }
public ObservableCollection<Project> ProjectListItems { get; set; }
public string TeamMemeberName { get; set; }
private Authentication _selectedItem { get; set; }
public string CurrentUserRoleName { get; set; }
public DelegateCommand<object> AddResourceClick { get; set; }
//public bool UserName { get; set; }
public int RowCount { get; set; }
#endregion Properties Variables
#endregion Properties
With Advance Thanks for solving this
Fijo Francis T
Why don't you try to set the ShowInsertRow property of the grid and add items through its functionality ? Once you click on that specific row, a new empty row will be displayed at the top of the grid. I believe this will be far more clean way for inserting new items.
Maya
the Telerik team