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
15 Answers, 1 is accepted
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
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>
Do you have an IterationStatusID property as a part of the business object filling up the data for the RadGridView ?
Maya
the Telerik team
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;
}
}
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
Please take a look at this troubleshooting article on the same topic.
Maya
the Telerik team
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.
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
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
The forum thread I mentioned may be found here.
Regards,Maya
the Telerik team
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
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.
Maya
the Telerik team
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
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.
Maya
the Telerik team
Please suggest !!!