Is this a bug of Radcombobox when it is inside a dataform?

2 posts, 0 answers
  1. Tai
    Tai avatar
    73 posts
    Member since:
    Jun 2010

    Posted 12 Nov 2010 Link to this post

    Hi

    I have a dataform with 2 Radcombobox inside:
    one is for the Period tables which currently has around 6-7 records now
    the other is for the Ledger table which currently has 1 records only

    My current problem is that The Ledger combobox works fine in the dataform but the Period combobox doesn't work at all and it always show the error "Period Id isn't in the correct format".

    One interesting thing is that i if move the xaml code of the Period radcombobox out of the dataform. Then it works perfectly.
    I don't really know what is going on.
    Plz help me

    <telerik:RadWindow x:Class="SilverFinancials.Windows.JournalPosting"
                       xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                       xmlns:helper="clr-namespace:SilverFinancials.Helpers"
        xmlns:SilverFinancials="clr-namespace:SilverFinancials"
                       xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
        mc:Ignorable="d" Width="825" Height="512"
        d:DesignHeight="462" d:DesignWidth="818">
         
        <Grid x:Name="LayoutRoot" Background="White">
            <Grid.Resources>
                <helper:PeriodList x:Key="periodList"/>
                <helper:LedgerList x:Key="ledgerList" />
            </Grid.Resources>
            <StackPanel Orientation="Vertical">
                <SilverFinancials:ToolBar x:Name="DocumentManagementToolBar" />
                <toolkit:DataForm x:Name="documentDF" AutoGenerateFields="True"   CommandButtonsVisibility="None" Height="248">
                    <toolkit:DataForm.EditTemplate>
     
                        <DataTemplate>
                            <StackPanel Orientation="Vertical">
    <TextBlock   Name="periodLabel" Text="Period:" Margin="82,0,0,0" />
                                <telerik:RadComboBox IsEnabled="False"  Name="periodRCB"  ItemsSource="{Binding Source={StaticResource periodList},Path=ListPeriodsByActive}" DisplayMemberPath="PeriodCode" SelectedValuePath="PeriodId"
                                         SelectedValue="{Binding PeriodId,Mode=TwoWay}"   Width="78" Margin="21,0,0,0" />
     
     
                                    <TextBlock   Name="ledgerIdLabel" Text="Ledger Id:" Margin="81,0,0,0" />
                                    <telerik:RadComboBox   IsEnabled="False" Name="ledgerIdRCB" VerticalAlignment="Center" Width="78"
                                        ItemsSource="{Binding Source={StaticResource ledgerList},Path=ListLedgersByBalancing}" DisplayMemberPath="LedgerCode" SelectedValuePath="LedgerId"
                                         SelectedValue="{Binding LedgerId,Mode=TwoWay,ValidatesOnDataErrors=True,NotifyOnValidationError=True}" Margin="3,0,0,0" />
     
     
     </StackPanel>
                        </DataTemplate>
                    </toolkit:DataForm.EditTemplate>
                </toolkit:DataForm>
     
                
     
            </StackPanel>
        </Grid>
    </telerik:RadWindow>


    my code behind

    using Telerik.Windows.Controls;
    using SilverFinancials.Windows.Posting.Journal_Posting;
    using System.ServiceModel.DomainServices.Client;
    using SilverFinancials.Web.Services;
    using SilverFinancials.Web.Models;
    using System.Linq;
    using System.Windows;
     
    using System.Windows.Data;
    using System;
    using System.Windows.Controls;
    using System.Windows.Input;
    using System.Collections.ObjectModel;
     
    namespace SilverFinancials.Windows
    {
        public partial class JournalPosting : RadWindow
        {
            private DocumentContext document_ctx = new DocumentContext();
     
            private ObservableCollection<Document> _documents;
            public JournalPosting()
            {
                InitializeComponent();
                //retrieving the list of businessEntity in order to support it to the Dataform for navigation
                document_ctx.Load(document_ctx.GetDocumentsQuery(), LoadBehavior.RefreshCurrent, (lop) =>
                {
                    if (!lop.HasError)
                    {
                        _documents = new ObservableCollection<Document>(lop.Entities);
                        //set the dataform itemssource
                       documentDF.ItemsSource = _documents;
                       
                       
                        
     
     
                    }
                    else
                    {
                        MessageBox.Show("Load document failed.");
                        lop.MarkErrorAsHandled();
                    }
                }, null);
            }
     
            private void searchRadBtn_Click(object sender, RoutedEventArgs e)
            {
     
            }
        }
    }


    my code for the helper PeriodList and Ledger List

    using System.Collections.Generic;
    using System.ServiceModel.DomainServices.Client;
    using SilverFinancials.Web.Models;
    using SilverFinancials.Web.Services;
     
    namespace SilverFinancials.Helpers
    {
        public class PeriodList
        {
            private IEnumerable<Period> _ListPeriodsByActive;
            private IEnumerable<Period> _ListPeriods;
            private PeriodsContext periods_ctx = new PeriodsContext();
            public IEnumerable<Period> ListPeriodsByActive
            {
                get
                {
                    if (_ListPeriodsByActive == null)
                    {
                        EntityQuery<Period> query = periods_ctx.GetPeriodsByActiveQuery();
                        LoadOperation<Period> op = periods_ctx.Load(query);
                        _ListPeriodsByActive = op.Entities;
                    }
                    return _ListPeriodsByActive;
                }
            }
            public IEnumerable<Period> ListPeriods
            {
                get
                {
                    if (_ListPeriods == null)
                    {
                        EntityQuery<Period> query = periods_ctx.GetPeriodsQuery();
                        LoadOperation<Period> op = periods_ctx.Load(query);
                        _ListPeriods = op.Entities;
                    }
                    return _ListPeriods;
                }
            }
        }
     
     
     
     
    public class LedgerList
        {
            private IEnumerable<Ledger> _ListLedgersByBalancing;
            private LedgerContext ledger_ctx = new LedgerContext();
            public IEnumerable<Ledger> ListLedgersByBalancing
            {
                get
                {
                    if (_ListLedgersByBalancing == null)
                    {
                        EntityQuery<Ledger> query = ledger_ctx.GetLedgersByBalancingQuery();
                        LoadOperation<Ledger> op = ledger_ctx.Load(query);
                        _ListLedgersByBalancing = op.Entities;
                    }
                    return _ListLedgersByBalancing;
                }
            }
        }
     
     
     
    }



    My code for the Operation service on the server side

    public IQueryable<Period> GetPeriodsByActive()
            {
                return this.ObjectContext.Periods.Where(p => p.Active == true).OrderBy(p=>p.PeriodCode);
            }
     
     
     
     /// <summary>
            /// return Ledgers with balancing = 1
            /// </summary>
            /// <returns></returns>
            public ObjectResult<Ledger> GetLedgersByBalancing()
            {
                return this.ObjectContext.LedgerByBalancing();
            }




  2. George
    Admin
    George avatar
    1332 posts

    Posted 18 Nov 2010 Link to this post

    Hi Tai,

    Please, refer to the following forum thread - http://www.telerik.com/community/forums/silverlight/combobox/radcombobox-within-dataform-did-not-apply-changes-after-committed.aspx

    Also, if you send us a sample project that reproduces the problem it would be very helpful in further investigating the problem. 

    Sincerely yours,
    George
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. DevCraft banner
Back to Top