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

Grid not showing any Rows

5 Answers 318 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ManniAT
Top achievements
Rank 2
ManniAT asked on 13 Jul 2013, 08:28 AM
Hi,

I use RadGridView in a MVVM WPF 4.5 application (running on windows 8 if that matters).
I use the latest internal build 2013.2.708.45 (before I use 617 with the same problem).

Everything worked fine till I added a user request (MessageBox) in the method which fills the data.
To reproduce this behavior I made simple app and had to find out that I don't even need the MessageBox to reproduce the problem.

The problem - RadGridView doesn't display any data until I "force" a redraw, either by changing the window size or by doing a change to the data.
To proof that my solution works in general I also added a WPF DataGrid - and yes this thing works as expected.

I simply created a WPF 4.5 application and changed MainWindow.xaml to
<Window
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="RGrid.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="2*" />
            <RowDefinition Height="2*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
 
        <telerik:RadGridView Grid.Row="0" ItemsSource="{Binding TransferModules}" SelectionMode="Extended" ShowInsertRow="false" CanUserDeleteRows="False" CanUserInsertRows="False" CanUserReorderColumns="False" ShowGroupPanel="False" AutoGenerateColumns="False" >
            <telerik:RadGridView.Columns>
                 
                <telerik:GridViewDataColumn Header="Modul" DataMemberBinding="{Binding ShortName}" Width="100" IsFilterable="False" IsReadOnly="True" />
                <telerik:GridViewDataColumn Header="Beschreibung" DataMemberBinding="{Binding Description}" Width="200" IsFilterable="False" IsReadOnly="True" />
                <telerik:GridViewDataColumn Header="Status" DataMemberBinding="{Binding TransferStatus}" Width="*" IsFilterable="False" IsReadOnly="True" />
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
        <DataGrid Grid.Row="1" ItemsSource="{Binding TransferModules}" SelectionMode="Extended" CanUserDeleteRows="False" CanUserReorderColumns="False" AutoGenerateColumns="False" >
            <DataGrid.Columns>
                <DataGridTextColumn Header="Modul"  Binding="{Binding ShortName}" Width="100" IsReadOnly="True" />
                <DataGridTextColumn Header="Beschreibung" Binding="{Binding Description}" Width="200" IsReadOnly="True" />
                <DataGridTextColumn Header="Status" Binding="{Binding TransferStatus}" Width="*" IsReadOnly="True" />
            </DataGrid.Columns>
        </DataGrid>
        <Button Grid.Row="2" Click="Button_Click" Content="Add item" HorizontalAlignment="Left" VerticalAlignment="Center" />
    </Grid>
</Window>


In code behind I have
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
 
namespace RGrid {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window {
        public class TM {
            public String ShortName { get; set; }
            public string Description { get; set; }
            public string TransferStatus { get; set; }
        }
        public ObservableCollection<TM> TransferModules { get; set; }
        private List<TM> _TModules;
        public MainWindow() {
            _TModules = new List<TM>();
            for (int nX = 0; nX < 5; nX++) {
                _TModules.Add(new TM { Description = "Des " + nX.ToString(), ShortName = "SN" + nX.ToString(), TransferStatus = "OK" });
            }
            //comment the following line to see if it fail without messagebox too
            _TModules[1].TransferStatus = "ERROR";
 
            TransferModules = new ObservableCollection<TM>();
            InitializeComponent();
            Loaded += MainWindow_Loaded;
            DataContext = this;
        }
 
        void MainWindow_Loaded(object sender, RoutedEventArgs e) {
            foreach (TM tM in _TModules) {
                if (tM.TransferStatus != "OK") {
                    if (MessageBox.Show("Data not OK." + Environment.NewLine + "Add anyways?", "Please confirm", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) != MessageBoxResult.Yes) {
                        continue;
                    }
                }
                TransferModules.Add(tM);
            }
        }
 
        private void Button_Click(object sender, RoutedEventArgs e) {
            TransferModules.Add(new TM { Description = "Des ", ShortName = "SN", TransferStatus = "OK" });
        }
    }
}


When I start the application the RadGridView shows no rows.
If I add a new row (with the button at the bottom) the data shows up as expected. The same happens if I change the window size.

Manfred

5 Answers, 1 is accepted

Sort by
0
Accepted
Yordanka
Telerik team
answered on 15 Jul 2013, 03:24 PM
Hi Manfred,

Thank you for the feedback.

I was able to reproduce the problem and we will investigate it further. I will contact you as soon as we have more information.
As a workaround you can set RadGridView.GroupRenderMode="Flat" and your scenario will work as expected. Please let me know if you have additional questions.
 
Regards,
Yordanka
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
ManniAT
Top achievements
Rank 2
answered on 15 Jul 2013, 05:46 PM
Hi Yordanka,

thank you for the (as always with telerik) fast and helpful answer.
I hope you updated my telerik points :)

Regards
Manfred
0
Yordanka
Telerik team
answered on 16 Jul 2013, 06:58 AM
Hi Manfred,

I've updated your Telerik points. Thank you for the valuable feedback.
 
Regards,
Yordanka
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Vuqar
Top achievements
Rank 2
answered on 15 Jan 2016, 12:21 PM

Hi, I have same issue when changing databound item in the CellEditEnded event. sample code

private void RadGridView_singleServices_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)
        {
            try
            {
                if (e.Cell.Column.UniqueName == "ExpanceId")
                {
                    MessageBoxResult res = MessageBox.Show("Would you ....?", "Request", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                    DataRowView drv = (DataRowView)((GridViewRowItem)e.Cell.ParentRow).DataContext;
                    if (res == MessageBoxResult.Yes)
                    {
                        RadGridView_singleServices.Items.EditItem(this.RadGridView_singleServices.CurrentItem);
                        InCard.HotelDataSet.SingleServicesRow cr = (InCard.HotelDataSet.SingleServicesRow)drv.Row;
                        Int32 expID = cr.ExpanceId;
                        var expns = from c in hotelDataSet.Expances
                                    where (c.ExpanceId == expID)
                                    select c;
 
                        var results = from ex in hotelDataSet.Expances
                                      join cd in hotelDataSet.CashDesks
                                      on ex.ExpCashDeskGUID equals cd.CashDeskGUID
                                      join or in hotelDataSet.Organization on cd.OrgGUID equals or.OrgGUID
                                      join cur in hotelDataSet.Currency on or.MainCurrency equals cur.CurrencyID
                                      where ex.ExpanceId == expID
                                      select new { CashDeskID = cd.CashDeskID, MainCurrencyID = or.MainCurrency, CurrentRate = cur.CurrentRate, DefaultSum = ex.DefaultSum };
 
                        foreach (var v in results)
                        {
                            drv.BeginEdit();
                            cr.PaymentID = 1;//need find first
                            cr.PaymSum = v.DefaultSum;
                            cr.CurrencyID = v.MainCurrencyID;
                            cr.CurrentRate = v.CurrentRate;
                            cr.WorkerUserID = LibMyCommon.CurrentUser().id;
                            cr.CashDeskID = v.CashDeskID;
                            drv.EndEdit();
                            return;
                        }
 
                    }
                }
 
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " in RadGridView_singleServices_CellEditEnded");
            }
        }

All changes applied, but not shown until resize window, and set GroupRenderMode="Flat" is not working for me.

0
Petya
Telerik team
answered on 20 Jan 2016, 11:22 AM
Hello Vuqar,

I'm a bit confused about the end result that you're trying to achieve. Could you elaborate a bit, please? If you can simplify the scenario in a sample project and send it over through a support ticket that would be ideal.

What comes to mind is that binding RadGridView when using DataTable should always be done to the DefaultView of that table in order to use the INotifyPropertyChanged and INotifyCollectionChanged support. Is that the case on your end?

Please also specify the exact version of Telerik UI for WPF which you're using.

Regards,
Petya
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
ManniAT
Top achievements
Rank 2
Answers by
Yordanka
Telerik team
ManniAT
Top achievements
Rank 2
Vuqar
Top achievements
Rank 2
Petya
Telerik team
Share this question
or