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

DataView and Row not selected when in cell edit

3 Answers 121 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Erez
Top achievements
Rank 1
Erez asked on 09 Jul 2009, 01:46 PM
Hello,

I have a small issue with a dataview and selecting a row while being in edit mode in a cell.

Below is the code-
If I start the below app, double click into one of the visible cells and than press on the
"ClickMe" button, the RowFilter is changed by code, the last line become visible, however
it is not selected even due I try to do so.

If I press again on the button,  the row is then selected.

Any ideas ?

Thanks,

Erez

P.S: "RadControls for WPF Q1 2009 SP2"




<Window x:Class="WpfToTelerikForum.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="333" Width="639" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
    <StackPanel Orientation="Vertical">
        <telerik:RadGridView Margin="12,20,-12,-20"
                             Name="radGridView1"
                             Loaded="radGridView1_Loaded" />
        <Button Margin="8" Height="50" Width="50" Content="ClickMe" Click="Button_Click"/>
    </StackPanel>
</Window>

 

 

using System;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.GridView;
using Telerik.Windows.Data;

namespace WpfToTelerikForum
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void radGridView1_Loaded(object sender, RoutedEventArgs e)
        {
            DataTable dt = new DataTable();
            DataView dv;

            dt.Columns.Add("Display", typeof(string));
            dt.Columns.Add("Number", typeof(int));

            dt.Rows.Add("show", 1);
            dt.Rows.Add("show", 2);
            dt.Rows.Add("hide", 3);

            dv = new DataView(dt);

            dv.RowFilter = "Display = 'show'";

            radGridView1.ItemsSource = dv;

        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DataTable dt;
            DataView dv;

            dv = ((DataView)radGridView1.ItemsSource);
            dt = dv.Table;

            dt.Rows[dt.Rows.Count-1]["Display"] = "show";

            radGridView1.Records[radGridView1.Records.Count-1].IsSelected = true;
        }
    }
}

 

 

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 13 Jul 2009, 02:57 PM
Hello Erez,

Please, try with this:

radGridView1.SelectedRecord = radGridView1.Records[radGridView1.Records.Count - 1];

Or even better,if you upgrade to Q2, which I strongly recommend, you can forget about records and work with the data items directly like this:

radGridView1.SelectedItem = dv[dv.Count - 1];

I hope this helps.

Kind regards,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Erez
Top achievements
Rank 1
answered on 20 Jul 2009, 01:54 PM
Hello,

Thanks, the 2009Q2 works better, however there still seems to be a bug.

If I double click into a cell and then adds a row to the datatable of the grid using code
and uses your advice, the row becomes selected, however focus also exists in the above cell.

Erez
0
Accepted
Rossen Hristov
Telerik team
answered on 23 Jul 2009, 07:24 AM
Hi Erez,

We will do our best to resolve this issue for an upcoming service pack.

Best wishes,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Erez
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Erez
Top achievements
Rank 1
Share this question
or