GridViewComboBoxColumn problem

16 posts, 0 answers
  1. sulagna
    sulagna avatar
    56 posts
    Member since:
    Sep 2010

    Posted 06 Dec 2010 Link to this post

    Hi,
    I have a GridViewComboBoxColumn but its not displaying during runtime.My entity structure is below.I am also getting data in the view model and that I am binding which is "IterationStatusCollection".
    namespace LeMonNext.Common.Entities
    {
        [DataContract(Name = "IterationStatus")]
        public class IterationStatus
        {
            [DataMember]
            public int IterationStatusID {get;set;}
            [DataMember]
            public string IterationStatusName { get; set; }
        }
    }

    <telerik:GridViewComboBoxColumn
                                                DataMemberBinding="{Binding IterationStatusID,Mode=TwoWay}" 
                                                SelectedValueMemberPath="IterationStatusID"
                                                DisplayMemberPath="IterationStatusName" 
                                                UniqueName="IterationStatus" Width="80"                                           
                                                ItemTemplate="{StaticResource StatusComboBoxCustomTemplate}" 
                                                IsReadOnlyBinding="{Binding Path=., Converter={StaticResource GridStausColumnReadOnlyConvertor}}"
                                                IsResizable="False"                    
                                                ItemsSourceBinding="{Binding IterationStatusCollection}">
                        <telerik:GridViewComboBoxColumn.Header>
                            <StackPanel>
                                <TextBlock Text="Status*" Style="{StaticResource CustomHeaderLabelStyle}" Width="48" />
                            </StackPanel>
                        </telerik:GridViewComboBoxColumn.Header>
                    </telerik:GridViewComboBoxColumn>

    Please help.
    Regards
    Sulagna
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 06 Dec 2010 Link to this post

    Hello sulagna,

    The DataMemberBinding property of the GridViewComboBoxColumn should be bound to a property of the business object filling up the source of the grid.  On the other hand the DisplayMemberPath and SelectedValueMemberPath properties should be a part of the source of the column.

    Greetings,
    Maya
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. sulagna
    sulagna avatar
    56 posts
    Member since:
    Sep 2010

    Posted 07 Dec 2010 Link to this post

    Hi,
    I tried with that but still its coming blank.So I tried to get the list in code behind like this 
     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 != null && IterationStatusCollection!=null)
                   if( e.Row is GridViewRow && !(e.Row is GridViewNewRow))
                    {
                        //bind  Status combobox.
                        (_radGridView.Columns["IterationStatus"] as GridViewComboBoxColumn).ItemsSource = IterationStatusCollection;

    I am getting data in row loaded event in item source but still the combobox is empty.I am also getting data in view model in "IterationStatusCollection".Can you verify the xaml is correct or not?
    My business entity is  
    public class IterationStatus
        {
            [DataMember]
            public int IterationStatusID {get;set;}
            [DataMember]
            public string IterationStatusName { get; set; }
        }

     <telerik:GridViewComboBoxColumn DataMemberBinding="{Binding IterationStatusID,Mode=TwoWay}" 
                                                SelectedValueMemberPath="IterationStatusID"
                                                DisplayMemberPath="IterationStatusName" 
                                                UniqueName="IterationStatus" Width="80"
                                                IsResizable="False"                    
                                                >
                        <telerik:GridViewComboBoxColumn.Header>
                            <StackPanel>
                                <TextBlock Text="Status*" Style="{StaticResource CustomHeaderLabelStyle}" Width="48" />
                            </StackPanel>
                        </telerik:GridViewComboBoxColumn.Header>
                    </telerik:GridViewComboBoxColumn>
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 07 Dec 2010 Link to this post

    Hello sulagna,

    Do you have an IterationStatusID property as a part of the business object filling up the data for the RadGridView ? 
     

    Kind regards,
    Maya
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  5. sulagna
    sulagna avatar
    56 posts
    Member since:
    Sep 2010

    Posted 07 Dec 2010 Link to this post

    Yes I also have an entity as Iteration and IterationStatusID as prop.This id I am binding to DataMember and other two are from IterationStatus entity.The grid that populates(jpeg provided) that gets all the values from "Iteration" business entity but the status column where combobox is there at the end gets the value from "IterationStatus" (provided) entity.Both entities have IterationStatusID.I am getting values of IterationList and IterationStatusList in view model but combobox items are blank.What should I do to get that?  

    namespace LeMonNext.Common.Entities
    {
        [DataContract(Name = "Iteration")]
        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;
                }
            }

  6. sulagna
    sulagna avatar
    56 posts
    Member since:
    Sep 2010

    Posted 07 Dec 2010 Link to this post

    Hi
    That got fixed.but the problem is when I click on the column entire column appears but when I click out side anywhere in the grid it the column values disappears.again when I click on the column combobox values appears.Can you plz let me know why its happening.
    I am attaching the screen shot.When I click outside entire column disappears
  7. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 07 Dec 2010 Link to this post

    Hi sulagna,

    Please take a look at this troubleshooting article on the same topic.
     

    All the best,
    Maya
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  8. sulagna
    sulagna avatar
    56 posts
    Member since:
    Sep 2010

    Posted 07 Dec 2010 Link to this post

     <telerik:GridViewComboBoxColumn DataMemberBinding="{Binding IterationStatusID,Mode=TwoWay}"
                                                SelectedValueMemberPath="IterationStatusId"
                                                DisplayMemberPath="IterationStatusName" 
                                                UniqueName="IterationStatus" Width="80"
                                                IsResizable="False" ItemsSource="{Binding Path=IterationCollection, Source={StaticResource mainPageViewModel}}">
    I added view model class <Local:ProjectIterationViewModel x:Key="mainPageViewModel" /> also binded the in view model
    Now I am not getting any items in the combobox.
  9. sulagna
    sulagna avatar
    56 posts
    Member since:
    Sep 2010

    Posted 07 Dec 2010 Link to this post

    First time when the page renders it doesnt show the combobox items but when I click some other tabs and come back to the same page data appears?Why this is happening?
    After solving the above prolem I have to insert a new record.Can you please share some code where I get some examples to save records.
    I have to sent a default value for Satrt Date which should be a Monday and readonly and EndDate by adding WorkingDays to it.How can I set some default values in new row that I need to insert like I am adding the picture? 

    Regards,
    Sulagna
  10. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 08 Dec 2010 Link to this post

    Hello sulagna,

    Considering your requirement about inserting new items, you may take a look at this forum thread for a reference where you will find both explanations and sample project demonstrating the correct approach.
    About adding items with default values, you may handle the AddingNewDataItem event like follows:

    private void CustomersGridView_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
            {
                Customer customer = new Customer();
                customer.City = "MyCity";          
                customer.Country = "MyCountry";
                customer.ContactTitle = "MyContactTitle";
     
                e.NewObject = customer;
            }

    As for the issue concerning the items in the ComboBox, may you verify if they are loaded during the initialization ? Is there anything specific that you do on loading your data ?

    Best wishes,
    Maya
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  11. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 08 Dec 2010 Link to this post

    Hello sulagna,

    The forum thread I mentioned may be found here

    Regards,
    Maya
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  12. sulagna
    sulagna avatar
    56 posts
    Member since:
    Sep 2010

    Posted 10 Dec 2010 Link to this post

    Hi Maya 
    Thank you so much for your help.

    By using AddingNewDataItem save problem got resolved.But the issue concerning the items in the ComboBox, is still there.How can I check if they get loaded during the initialization ?
    Refreshing the page I get the data or after navigating to other pages and coming back I get the data.

    My other issue is I dont know how to change a data in cell dynamically in client side on the same grid by changing date value of another cell of that grid.
    I have attached the jpeg.By changing the EndDate the the WorkingDays (Red circle) should change dynamically means it(working days value) should increase/decrease depending on the date selection.

    Thanks,
    Sulagna

  13. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 11 Dec 2010 Link to this post

    Hello sulagna,

    I am sending you a sample project illustrating a sample implementation of GridViewComboBoxColumn using RIA Services. 
    Considering your second requirement, I believe you got the answer in the other forum thread you had started. 

    Regards,
    Maya
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  14. sulagna
    sulagna avatar
    56 posts
    Member since:
    Sep 2010

    Posted 13 Dec 2010 Link to this post

    Thanks for sharing the source code but I was not able to run it because it was giving some run time framework exception.I opened it in VS2010 ,silverlight4 and ran.The moment it loads the grid application breaks.

    My other problem is I want to keep a track of old record/collection how can I achieve that and in which event?
    After the row gets updated it loses its previous value. I know inside RowValidating event there is e.OldValues.
    and I have a business entity "Iteration" and I want the old record of Iteration row. Can I get the old record like this Iteration _iterationValidating = e.Row.DataContext as Iteration;?

    Regards,
    Sulagna
  15. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 13 Dec 2010 Link to this post

    Hello sulagna,

    The application uses Northwind database so it may breaks if you do not have it. What are the exceptions you are getting ? Furthermore, you may open the code so that to examine the proper parts of it.
    Considering your second requirement, you may save the collection before making any changes in a separate instance and use it when you require the old values.
     

    All the best,
    Maya
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  16. Moumita
    Moumita avatar
    2 posts
    Member since:
    Feb 2013

    Posted 10 Feb 2013 Link to this post

    How to bind a RadGridview in another RadgridView column ??
    Please suggest !!!
Back to Top