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

[Solved] Grid view combobox

18 Answers 238 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
sulagna
Top achievements
Rank 1
sulagna asked on 17 Dec 2010, 08:54 AM
Hi,
I have a grid view combobox columns.In that there are 3 items displaying.I want to hide some of them depending on conditions.How can I do that?

Thanks,
Sulagna

18 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 17 Dec 2010, 09:05 AM
Hello sulagna,

Before giving a solution I will need to know some details -
1. Do you need to  hide some items only for a certain row of RadGridView or this should affect the combo boxes in all rows.

2. What are the conditions controlling how many  and which items to display in the combo box ?

Kind regards,
Pavel Pavlov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
sulagna
Top achievements
Rank 1
answered on 17 Dec 2010, 10:24 AM
Hi,
I have 3 items in status column.They are Closed,Current,Waiting.
Condition 1:If the status is Current then the combobox should have Current and Closed status.
Condition 2:If the status is Waiting then the combobox should have Current and Waiting status.And it happens when its a new row.New row is always in Waiting status
I have attached the screen shot for your ref.

Thanks
Sulagna
0
Pavel Pavlov
Telerik team
answered on 17 Dec 2010, 12:03 PM
Hello sulagna,

The recommended approach here would b as follows:

In the business object - the one with the status property you need to expose a new property e.g. AvailableStatuses - an observable collection of the available statuses the user can chose from .

Then you can bind the ItemsSource of the column , using the ItemsSource property e.g.

XAML:
ItemsSourceBinding = {Binding AvailableStatuses}.

The AvailableStatuses property should return a collection of filtered  statuses based on the current one.

Let me know in case you find troubles while implementing this.


Pavel Pavlov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
sulagna
Top achievements
Rank 1
answered on 27 Dec 2010, 09:07 AM
Hi Pavlov,
Thanks for multi column combobox help.It got resolved.
Coming to status column.I already tried your approach but in here its different.
I have one "Iteration" entity and "IterationStatus" entity.

 public class Iteration
    {
        private int _iterationNumber;
        private string _iterationMainGoal;

        [DataMember]
        public int IterationID { get; set; }

        [DataMember]
        public int IterationNumber
        {
            get { return _iterationNumber; }
            set { _iterationNumber = value; }
        }

        [DataMember]
        public string IterationMainGoal
        {
            get { return _iterationMainGoal; }
            set { _iterationMainGoal = value; }
        }

        [DataMember]
        public DateTime StartDate { get; set; }

        [DataMember]
        public DateTime EndDate { get; set; }

        [DataMember]
        public int IterationStatusID { get; set; }

        [DataMember]
        public string IterationStatus { get; set; }

        [DataMember]
        public int NoOfWorkingDays { get; set; }

        [DataMember]
        public int ProjectID { get; set; }

        public string IterationInfo
        {
            get
            {
                return this._iterationMainGoal.StartsWith("ITR") ? this._iterationMainGoal : this._iterationNumber + " : " + this._iterationMainGoal;
            }
        }

public class IterationStatus
    {
        [DataMember]
        public int IterationStatusId {get;set;}
        [DataMember]
        public string IterationStatusName { get; set; }
    }
My combobox is changing values depending on conditions but the problem is its holding only last condition values.(refer attachment)
I get list of iteration and list of iterationStatus both in view model I need to bind Iteration Status in status column and iteration to the same grid.

Condition is added in another entity

public class IterationStatusList : INotifyPropertyChanged
    {
        public int IterationStatusId
        { get; set; }

        public string IterationStatusName
        { get; set; }
        private IList<IterationStatus> _status;
        public IList<IterationStatus> StatusList
        {
            get
            {

                return this._status;
            }
            set
            {
                if (_status != value)
                {
                    _status = value;
                    OnPropertyChanged("StatusList");
                }
            }
        }
        private IList<IterationStatus> _allStatus;
        public IList<IterationStatus> AllStatusList
        {
            get
            {

                return this._allStatus;
            }
            set
            {
                if (_allStatus != value)
                {
                    _allStatus = value;
                    OnPropertyChanged("AllStatusList");
                    GetStatusList();
                }
            }
        }
        /// <summary>
        /// Get StatusList as per StatusId
        /// </summary>
        private void GetStatusList()
        {
            switch (this.IterationStatusId)
            {
                case 7:
                    this.StatusList = (from _statusRead in this.AllStatusList
                                       where _statusRead.IterationStatusId != 9
                                       select _statusRead).ToList<LeMonNext.Client.Entities.IterationStatus>();
                    break;
                case 8:
                    this.StatusList = (from _statusRead in this.AllStatusList
                                       where _statusRead.IterationStatusId != 7
                                       select _statusRead).ToList<LeMonNext.Client.Entities.IterationStatus>();
                    break;

                default:
                    this.StatusList = (from _statusRead in this.AllStatusList
                                       select _statusRead).ToList<LeMonNext.Client.Entities.IterationStatus>();
                    break;
            }
        }
        public event PropertyChangedEventHandler PropertyChanged;

        private void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

0
Maya
Telerik team
answered on 28 Dec 2010, 10:41 AM
Hi sulagna,

May you provide a bit more details about the exact issue you are experiencing ? Firstly, how do you define the GridViewComboBoxColumn, how do you set its ItemsSource ? Basically, you may expose a property as mentioned earlier holding the result of the GetStatusList() and bind it to the source of the column. Furthermore, what exactly do you imply by saying only the last status is retained ?
 

Kind regards,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
sulagna
Top achievements
Rank 1
answered on 13 Jan 2011, 08:00 AM
Hi Maya,
I am explaining the problem in detail.I have a IterationStatusCollection property in view model which gets the status list current,waiting and closed.They are the combo box list tems.nside row loaded I am running 2 linq queries to fill the StatusList as per my requirement.This StatusList I am binding to the xaml.

public void RadProjectIterationGridView_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
        {
            GridViewRow row = e.Row as GridViewRow;
            //Get parent grid.
            RadGridView _radGridView = e.GridViewDataControl as RadGridView;          
            if (e.Row is GridViewRow && !(e.Row is GridViewNewRow))
            {
                Iteration iteration = e.DataElement as Iteration;
                  if (e.Row.Cells[5].Content != null)
                    {                                       
                        if(((LeMonNext.Common.Entities.Iteration)(((System.Windows.FrameworkElement)(e.Row.Cells[4].Content)).DataContext)).IterationStatusID.ToString() == LeMonNextResource.IterationClosedStatusID)
                        {
                            e.Row.Cells[5].IsEnabled = false;
                            e.Row.IsEnabled = false;
                        }
                        else
                            if (iteration != null & e.Row.Cells[5].Content != null)
                                if (iteration.IterationStatus == LeMonNextResource.IterationCurrentStatus && iteration.IterationID != 0)
                                {
                                    this.StatusList = (from _statusRead in this.IterationStatusCollection
                                                       where _statusRead.IterationStatusId != 7
                                                       select _statusRead).ToList<IterationStatus>();
                                    (_radGridView.Columns["IterationStatus"] as GridViewComboBoxColumn).ItemsSource = StatusList;
                                                                       
                                }

                        if (iteration.IterationStatus == LeMonNextResource.IterationWaitingStatus && iteration.IterationID == 0)
                        {
                            this.StatusList = (from _statusRead in this.IterationStatusCollection
                                               where _statusRead.IterationStatusId != 9
                                               select _statusRead).ToList<IterationStatus>();
                            (_radGridView.Columns["IterationStatus"] as GridViewComboBoxColumn).ItemsSource = StatusList;                           
                        }                       
                    }               
            }
        }

In new row I am also adding the required list but the problem is when I click on the current iteration(refer WrongCurrentStatusList.jpg) it holds the last updated listof Waiting status which is wrong it should hold its own list.To get required list i run individual query.
Plz help.
public void RadProjectIterationGridView_AddingNewDataItem(object sender, GridView.GridViewAddingNewEventArgs e)
        {
            RadGridView _radGridView = e.OwnerGridViewItemsControl as RadGridView;
            IEnumerator<Iteration> iterEnum = IterationCollection.GetEnumerator();
            int i = 0;
            //Finding the current row
            while (i < IterationCollection.Count)
            {
                ++i;
                iterEnum.MoveNext();
            }
            Iteration iter = iterEnum.Current;
            //Finding the duration of the project
            if (ClientStateService.SelectedProject.ProjectId != 0)
            {
                ProjectIterationHelper projectIterationHelper = new ProjectIterationHelper();
                Iteration newIteration = projectIterationHelper.CreateNewIteration(ClientStateService.SelectedProject, iter);

                if (newIteration.IterationID==0 && newIteration.IterationStatus == LeMonNextResource.IterationWaitingStatus)
                {
                    this.StatusList = (from _statusRead in this.IterationStatusCollection
                                       where _statusRead.IterationStatusId != 9
                                       select _statusRead).ToList<IterationStatus>();
                    (_radGridView.Columns["IterationStatus"] as GridViewComboBoxColumn).ItemsSource = StatusList;
                }
                e.NewObject = newIteration;
            }
        }
My xaml where StstusList is there
<telerik:GridViewComboBoxColumn   
         DataMemberBinding="{Binding IterationStatusID,Mode=TwoWay}"
                                            SelectedValueMemberPath="IterationStatusId"
                                            DisplayMemberPath="IterationStatusName" 
                                            UniqueName="IterationStatus" Width="80"
                                            IsResizable="False" ItemsSource="{Binding Path = StatusList,Mode=TwoWay}"                
                                            HeaderCellStyle="{StaticResource CustomHeaderCellStyle}"                                           
                                            CellTemplate="{StaticResource StatusComboBoxSelectionBoxTemplate}">
                </telerik:GridViewComboBoxColumn>
What should I do to update the list everytime??lease help.
My StsusList in view model:
public IList<IterationStatus> StatusList
        {    get
            {    return this._status;            }
            set
            {
                if (_status != value)
                {   _status = value;
                    OnPropertyChanged("StatusList");
                }
            }
        }
Thanks,
Sulagna

0
Maya
Telerik team
answered on 17 Jan 2011, 05:31 PM
Hi sulagna,

Please send us a sample project demonstrating the issues you specified or modify those I previously sent so that they fit your requirements. This will be the most straightforward way for me to clear the things up and provide you with an accurate solution.
 

Best wishes,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
sulagna
Top achievements
Rank 1
answered on 21 Jan 2011, 07:27 AM
Hi,

Thanks got resolved.On clicking of any cell, the items get displayed inside the combo box but that selected item doesnt remain in the cell(red circled).How can I hold that value in the cell position when the combo box drops down?

Regards
Sulagna
0
Maya
Telerik team
answered on 21 Jan 2011, 10:49 AM
Hello sulagna,

I have tried to reproduce this issue, but I was not able to. I have tested in on the sample project I recently sent to you - GridViewComboBoxColumn_RIA in this forum thread. Are you able to reproduce the same behavior there ? Furthermore, do you use a GridViewComboBoxColumn or you define a RadComboBox in the CellEditTemplate of the column ? Generally, this issue may be caused by inappropriate settings of the properties of the RadComboBox/ GridViewComboBoxColumn.

All the best,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
sulagna
Top achievements
Rank 1
answered on 21 Jan 2011, 11:04 AM
Mine is gridviewcombobox column.I have the same xaml sent earlier.

<telerik:GridViewComboBoxColumn
                                            DataMemberBinding="{Binding IterationStatusName,Mode=TwoWay}"
                                            SelectedValueMemberPath="IterationStatusName"
                                            DisplayMemberPath="IterationStatusName"   
                                            UniqueName="IterationStatus" Width="80"
                                            IsResizable="False" ItemsSource="{Binding Path = StatusList,Mode=TwoWay}"
                                            HeaderCellStyle="{StaticResource CustomHeaderCellStyle}"                                           
                                            >
                    <telerik:GridViewComboBoxColumn.Header>
                        <StackPanel>
                            <TextBlock Text="Status*" Style="{StaticResource CustomHeaderLabelStyle}" Width="48" />
                        </StackPanel>
                    </telerik:GridViewComboBoxColumn.Header>

                    <telerik:GridViewComboBoxColumn.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="{Binding IterationStatusName}" Grid.Column="0"></TextBlock>
                            </Grid>
                        </DataTemplate>
                    </telerik:GridViewComboBoxColumn.ItemTemplate>
                    <telerik:GridViewComboBoxColumn.CellTemplate>
                        <DataTemplate >
                            <TextBlock Text="{Binding IterationStatus}" HorizontalAlignment="Left"  />
                        </DataTemplate>
                    </telerik:GridViewComboBoxColumn.CellTemplate>
                </telerik:GridViewComboBoxColumn>

Thanks,
Sulagna

0
Maya
Telerik team
answered on 24 Jan 2011, 05:37 PM
Hello sulagna,

I am not able to reproduce the issue based on the provided information. However, looking at your previous posts and the images attached(CorrectCurrentStatusList.jpg for example), I can see that you do not experience this behavior before and the value is kept during editing. May you verify what changes have you made ? Furthermore, in the post with the mentioned images attached, the definition of your GridViewComboBoxColumn is:

<telerik:GridViewComboBoxColumn   
         DataMemberBinding="{Binding IterationStatusID,Mode=TwoWay}"
             SelectedValueMemberPath="IterationStatusID"
             DisplayMemberPath="IterationStatusName"
                              UniqueName="IterationStatus" Width="80"
             IsResizable="False"
             ItemsSource="{Binding Path = StatusList,Mode=TwoWay}"                      
             HeaderCellStyle="{StaticResource CustomHeaderCellStyle}"                                                                   CellTemplate="{StaticResource StatusComboBoxSelectionBoxTemplate}">
</telerik:GridViewComboBoxColumn>

While in the last post the column was defined as:
<telerik:GridViewComboBoxColumn
          DataMemberBinding="{Binding IterationStatusName,Mode=TwoWay}"
          SelectedValueMemberPath="IterationStatusName"
          DisplayMemberPath="IterationStatusName"  
                       UniqueName="IterationStatus" Width="80"
          IsResizable="False"
          ItemsSource="{Binding Path = StatusList,Mode=TwoWay}"
          HeaderCellStyle="{StaticResource CustomHeaderCellStyle}" >

May you try out the first scenario again ? 

Kind regards,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
sulagna
Top achievements
Rank 1
answered on 28 Jan 2011, 10:30 AM

<

 

telerik:GridViewComboBoxColumn

 

 

 

DataMemberBinding="{Binding IterationStatusID,Mode=TwoWay}"

 

SelectedValueMemberPath

 

 

="IterationStatusID"

 

 

 

 

DisplayMemberPath="IterationStatusName"

 

 

 

UniqueName="IterationStatus"Width="80"

 

IsResizable

 

 

="False"

 

ItemsSource

 

 

="{Binding Path = StatusList,Mode=TwoWay}"

 

HeaderCellStyle

 

 

="{StaticResource CustomHeaderCellStyle}" CellTemplate="{StaticResource StatusComboBoxSelectionBoxTemplate}">

 

</

 

telerik:GridViewComboBoxColumn>

 

yes if i replace with this piece then its retain the value in edit mode but the previous problem arises like if I select a different value from drop down it holds the previous value.If I change everything to IterationStatusName then it works fine but doesnt hold the value in edit mode.
So, what should I do so that the value remains instead of empty cell when it drops down in edit mode ?

Thanks,
Sulagna
0
Maya
Telerik team
answered on 28 Jan 2011, 10:50 AM
Hello sulagna,

Unfortunately, I have reached my limits on providing any solution based only on the code-snippets you have given. Please isolate your issue and exact scenario in a sample project or use one of those I previously sent and attach it in a support ticket. Thus I will be able to make a profound investigation on your exact requirements and settings and suggest any further.  

 
Best wishes,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
sulagna
Top achievements
Rank 1
answered on 28 Jan 2011, 12:22 PM
Hi Maya,

Thank you so much for all your help but even after numerous try I am also not able to find any solution.

Can you let me know the steps how can I upload my sample by creating support ticket and how much size is allowed?  

Thanks,

Sulagna

0
Maya
Telerik team
answered on 02 Feb 2011, 03:49 PM
Hi sulagna,

May you try to provide me with the most recent version of your code - the one responsible for the definition of the grid, the GridViewComboBoxColumn, setting their ItemsSource-s and the exact implementation of the two business objects - the one for the grid and the one for the column. Basically, any relevant information would be helpful so that I could try to reproduce your scenario and create a sample project based on the provided details.
As far as the attachments are concerned, you may send us a sample project once a support ticket is opened.  

Kind regards,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
sulagna
Top achievements
Rank 1
answered on 03 Feb 2011, 07:51 AM
Hi Maya,
Is there any way I can attach my .cs/code files?I explored the entire site but didn't find any way of attaching my solution or files.All I see is only.gif,jpeg..png,.jpg files are allowed.If there is any please let me know else I'll copy paste my code here.

Thanks,
Sulagna
0
sulagna
Top achievements
Rank 1
answered on 03 Feb 2011, 09:52 AM
-------------------------------------xaml---------------------------------------------------
<
telerik:RadGridView x:Name="RadProjectIterationGridView" CanUserFreezeColumns="False" 
                             GridLinesVisibility="Horizontal"    
                             ItemsSource="{Binding IterationCollection}"                                
                             AutoGenerateColumns="False" IsReadOnly="{Binding IsProjectIterationGridReadOnly}"                                
                             ActionOnLostFocus="CommitEdit" Style="{StaticResource CustomGridStyle}" 
                             Margin="0,0,0,0" IsBusy="{Binding IsGridBusy}" 
                             Height="538" Grid.Row="1">
            <telerik:RadGridView.Columns >
  
                <!--Column For S.No-->
                <telerik:GridViewDataColumn DataMemberBinding="{Binding IterationNumber}"     
                                            HeaderTextAlignment="Center" UniqueName="SlNo"  Header="S.No" TextAlignment="Left"  >
                </telerik:GridViewDataColumn>
  
                <!--Column For Assign Iteration Goal-->
                <telerik:GridViewDataColumn DataMemberBinding="{Binding IterationMainGoal}" 
                                            HeaderTextAlignment="Center" Header="Iteration Goal*" TextAlignment="Left" 
                                            UniqueName="Iteration Goal">
                </telerik:GridViewDataColumn>
  
                <!--Column For Assign Start Date-->
                <telerik:GridViewDataColumn DataMemberBinding="{Binding StartDate}" 
                                            Header="Start Date"  HeaderTextAlignment="Center" 
                                            TextAlignment="Left"
                                            DataFormatString = "dd-MMM-yyyy"/>
                <!--Column For Assign End Date-->
                <telerik:GridViewDataColumn DataMemberBinding="{Binding EndDate,Mode=TwoWay}" 
                                            HeaderTextAlignment="Center" Header="End Date*" 
                                            TextAlignment="Left" IsSortable="True" 
                                            DataFormatString = "dd-MMM-yyyy" UniqueName="EndDate">
  
                </telerik:GridViewDataColumn>
                <!--Column For Assign Working Days-->
                <telerik:GridViewDataColumn DataMemberBinding="{Binding NoOfWorkingDays}"   
                                            HeaderTextAlignment="Center" Header="Working Days" 
                                            TextAlignment="Left" UniqueName="WorkingDays">
                </telerik:GridViewDataColumn>
  
                <!--Column For Iteration Status-->
                <telerik:GridViewComboBoxColumn 
                                            DataMemberBinding="{Binding IterationStatusName,Mode=TwoWay}" 
                                            SelectedValueMemberPath="IterationStatusName"
                                            DisplayMemberPath="IterationStatusName"    
                                            UniqueName="IterationStatus" Width="80"
                                            IsResizable="False" ItemsSource="{Binding Path = StatusList,Mode=TwoWay}"
                                            HeaderCellStyle="{StaticResource CustomHeaderCellStyle}"                                            
                                            >
                    <telerik:GridViewComboBoxColumn.Header>
                        <StackPanel>
                            <TextBlock Text="Status*" Style="{StaticResource CustomHeaderLabelStyle}" Width="48" />
                        </StackPanel>
                    </telerik:GridViewComboBoxColumn.Header>
  
                    <telerik:GridViewComboBoxColumn.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="{Binding IterationStatusName}" Grid.Column="0"></TextBlock>
                            </Grid>
                        </DataTemplate>
                    </telerik:GridViewComboBoxColumn.ItemTemplate>
                    <telerik:GridViewComboBoxColumn.CellTemplate>
                        <DataTemplate >
                            <TextBlock Text="{Binding IterationStatus}" HorizontalAlignment="Left"  />
                        </DataTemplate>
                    </telerik:GridViewComboBoxColumn.CellTemplate>
                </telerik:GridViewComboBoxColumn>
                <!--Column For id.No-->
                <telerik:GridViewDataColumn DataMemberBinding="{Binding IterationID}" IsVisible="False"     
                                            HeaderTextAlignment="Center" UniqueName="ItrId"  Header="IterId" TextAlignment="Left"  >
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns >
        </telerik:RadGridView>
-----------------------------------------------------ViewModel.cs--------------------------------------public void RadProjectIterationGridView_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
        {
            RadGridView _radGridView = e.OwnerGridViewItemsControl as RadGridView;
            (_radGridView.Columns["WorkingDays"] as GridViewDataColumn).IsReadOnly = true;
            (_radGridView.Columns["SlNo"] as GridViewDataColumn).IsReadOnly = true;
            IEnumerator<Iteration> iterEnum = IterationCollection.GetEnumerator();
            int i = 0;
            //Finding the current row 
            while (i < IterationCollection.Count)
            {
                ++i;
                iterEnum.MoveNext();
            }
            Iteration iter = iterEnum.Current;
            //Finding the duration of the project
            if (ClientStateService.SelectedProject.ProjectId != 0)
            {
                ProjectIterationHelper projectIterationHelper = new ProjectIterationHelper();
                Iteration newIteration = projectIterationHelper.CreateNewIteration(ClientStateService.SelectedProject, iter);
  
                if (newIteration.IterationID == 0 && newIteration.IterationStatus == LeMonNextResource.IterationWaitingStatus)
                {
                    this.StatusList = WaitingList;
                }
                e.NewObject = newIteration;
            }
        }
 public void RadProjectIterationGridView_CellValidating(object sender, Telerik.Windows.Controls.GridViewCellValidatingEventArgs e)
        {IsValidationChecked = false;
            OnPropertyChanged("IsValidationChecked");
            switch (e.Cell.Column.UniqueName)
            {case "IterationStatus":
                    if (e.NewValue == null)
                    {
                        e.IsValid = false;
                        IsValidationChecked = true;
                        OnPropertyChanged("IsValidationChecked");
                        MessageBox.Show(LeMonNextResource.StatusRequired, LeMonNextResource.MessageBoxCaption, MessageBoxButton.OK);
                    }
                    if (e.NewValue != null)
                    {
                        if (e.NewValue.ToString() == LeMonNextResource.IterationClosedStatus)
                        {
                            MessageBox.Show("Once you close an iteration, You won't be able to make further changes to it." +
                            "\n" + "Are you sure, You want to continue?");
                            foreach (Iteration itr in IterationCollection)
                            {
                                if (itr.IterationID == ((Iteration)(((System.Windows.FrameworkElement)(e.Row.Cells[1].Content)).DataContext)).IterationID)
                                    ((Iteration)(((System.Windows.FrameworkElement)(e.Row.Cells[5].Content)).DataContext)).IterationStatus = e.NewValue.ToString();
                            }
                        }
                        if (e.NewValue.ToString() == LeMonNextResource.IterationCurrentStatus)
                        {
                            foreach (Iteration itr in IterationCollection)
                            {
                                if (itr.IterationID == ((Iteration)(((System.Windows.FrameworkElement)(e.Row.Cells[1].Content)).DataContext)).IterationID)
                                    ((Iteration)(((System.Windows.FrameworkElement)(e.Row.Cells[5].Content)).DataContext)).IterationStatus = e.NewValue.ToString();
                            }
                        }
                        if (e.NewValue.ToString() == LeMonNextResource.IterationWaitingStatus)
                        {
                            foreach (Iteration itr in IterationCollection)
                            {
                                if (itr.IterationID == ((Iteration)(((System.Windows.FrameworkElement)(e.Row.Cells[1].Content)).DataContext)).IterationID)
                                    ((Iteration)(((System.Windows.FrameworkElement)(e.Row.Cells[5].Content)).DataContext)).IterationStatus = e.NewValue.ToString();
                            }
                        }
                        //checking for duplicate current iteration
                        if (e.NewValue.ToString() == LeMonNextResource.IterationCurrentStatusID && ((LeMonNext.Common.Entities.Iteration)(((System.Windows.FrameworkElement)(e.Row.Cells[5].Content)).DataContext)).IterationStatus != "Current")
                        {
                            foreach (Iteration itr in Grid.Items)
                            {
                                var oldValue = itr.IterationStatus;
                                if (oldValue.ToString() == "Current")
                                {
                                    MessageBox.Show("Two iterations cannot be in current status");
                                    IsValidationChecked = true;
                                    e.IsValid = false;
                                    OnPropertyChanged("IsValidationChecked");
                                    break;
                                }
                            }
                        }
                    }
                    break;
}
public void RadProjectIterationGridView_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
        {
            if (e.EditOperationType == GridViewEditOperationType.Edit)
            {
                Iteration editedIteration = e.NewData as Iteration;
                if (IterationCollection != null)
                {
                    IterationStatus iteration = (from IterationStatus iterationQuery in IterationStatusCollection
                                                 where iterationQuery.IterationStatusName == editedIteration.IterationStatus
                                                 select iterationQuery).ToList<IterationStatus>()[0];
                    //based on status id iteration is saved
                    editedIteration.IterationStatusID = iteration.IterationStatusId;
                }
                editedIteration.NoOfWorkingDays = ProjectIterationHelper.weekdaysBetween(editedIteration.StartDate, editedIteration.EndDate);
                EditedIterationList.Add(editedIteration);
            }
            if (e.EditOperationType == GridViewEditOperationType.Insert)
            {
                Iteration insertIteration = e.NewData as Iteration;
                insertIteration.NoOfWorkingDays = ProjectIterationHelper.weekdaysBetween(insertIteration.StartDate, insertIteration.EndDate);
                NewIterationList.Add(insertIteration);
            }
        }
public void RadProjectIterationGridView_BeginningEdit(object sender, Telerik.Windows.Controls.GridViewBeginningEditRoutedEventArgs e)
        {
            GridViewRow row = e.Row as GridViewRow;
            if (e.Row is GridViewRow && !(e.Row is GridViewNewRow))
                if (((Iteration)(((System.Windows.FrameworkElement)(e.Row.Cells[4].Content)).DataContext)).IterationStatusID.ToString() == LeMonNextResource.IterationCurrentStatusID)
                {
                    if (CurrentList != null)
                        this.StatusList = CurrentList;
                }
            if (((Iteration)(((System.Windows.FrameworkElement)(e.Row.Cells[4].Content)).DataContext)).IterationStatusID.ToString() == LeMonNextResource.IterationWaitingStatusID)
            {
                if (WaitingList != null)
                    this.StatusList = WaitingList;
            }
            OnPropertyChanged("StatusList");
        }
 private IList<IterationStatus> _status;
        private IList<IterationStatus> _waitingList;
        private IList<IterationStatus> _currentList;
        public RadGridView Grid
        {
            get;
            set;
        }
        public ObservableCollection<Iteration> IterationCollection
        {
            get;
            set;
        }
        public ObservableCollection<IterationStatus> IterationStatusCollection
        {
            get;
            set;
        }
        public IList<IterationStatus> WaitingList
        {
            get
            {
                if (IterationStatusCollection != null)
                    _waitingList = (from _statusRead in this.IterationStatusCollection
                                    where _statusRead.IterationStatusId != 9
                                    select _statusRead).ToList<IterationStatus>();
                return _waitingList;
            }
            set
            {
                if (_waitingList != value)
                {
                    _waitingList = value;
                    OnPropertyChanged("WaitingList");
                }
            }
        }
        public IList<IterationStatus> CurrentList
        {
            get
            {
                if (IterationStatusCollection != null)
                    _currentList = (from _statusRead in this.IterationStatusCollection
                                    where _statusRead.IterationStatusId != 7
                                    select _statusRead).ToList<IterationStatus>();
                return _currentList;
            }
            set
            {
                if (_currentList != value)
                {
                    _currentList = value;
                    OnPropertyChanged("CurrentList");
                }
            }
        }
        public IList<IterationStatus> StatusList
        {
            get
            {
                return this._status;
            }
            set
            {
                if (_status != value)
                {
                    _status = value;
                    OnPropertyChanged("StatusList");
  
                }
            }
        }
        public string IterationStatus { get; set; }
        ObservableCollection<Iteration> editedIterationList;
        ObservableCollection<Iteration> newIterationList;
        public ObservableCollection<Iteration> EditedIterationList
        {
            get
            {
                if (editedIterationList == null)
                {
                    editedIterationList = new ObservableCollection<Iteration>();
                }
                return editedIterationList;
            }
        }
        public ObservableCollection<Iteration> NewIterationList
        {
            get
            {
                if (newIterationList == null)
                {
                    newIterationList = new ObservableCollection<Iteration>();
                }
                return newIterationList;
            }
        }
        public ObservableCollection<Iteration> OldIterationList
        {
            get;
            set;
        }
        private bool _isGridBusy = true;
        public bool IsGridBusy
        {
            get
            {
                return _isGridBusy;
            }
            set
            {
                _isGridBusy = value;
                OnPropertyChanged("IsGridBusy");
            }
        }
        private bool _isValidationChecked = true;
        public bool IsValidationChecked
        {
            get
            {
                return _isValidationChecked;
            }
            set
            {
                _isValidationChecked = value;
                OnPropertyChanged("IsValidationChecked");
            }
        }
Hi,

I have provided my xaml and viewmodel files above. You can refer them or create a small app using above code whichever is convenient .If  you have any doubts regarding my code plz ask.


Thanks,
Sulagna
0
Maya
Telerik team
answered on 03 Feb 2011, 12:44 PM
Hi sulagna,

Please take another look at the sample projects referring the usage of the GridViewComboBoxColumn previously attached in the forum threads you started. If you could use them for a reference or try to make a slight change on them so that they fit your requirements, let us know how we can easily reproduce your scenario on those projects.  
In case they are not appropriate, please send us a sample project with your requirements, the definition of the RadGridView, its ViewModels and business objects. Thus our communication will get far more consistent and clear. 
Generally, you may attach a project once you have downloaded our products - Trial or Dev. As I can see that for the time being you have no downloads, I may encourage you to take a step further and download our Trial version for example (http://www.telerik.com/download.aspx) and install them on your computer. Once you complete this, you will be able to submit a support tickets with 72 hours response time and attach sample projects to them. The trial period is 60 days which will probably be enough for you to evaluate the product.

 
All the best,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
GridView
Asked by
sulagna
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
sulagna
Top achievements
Rank 1
Maya
Telerik team
Share this question
or