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

Row Details for New Row

5 Answers 123 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 03 Jun 2010, 07:30 PM
I have a details presenter display the full detail of a row in the column to the right of my GridView.  This allows the user to look at and edit certain common attributes in the grid and see the complete record detail for only the selected record.  Is it possible to have this presenter populated when the user is inserting a new row?  As the grid works now the details presenter continues to show the data for the previously selected row which is rather confusing.  I assume I could just deselect the row when the new entry panel is started to get rid of the confusion but the preferable behavior would be for it to allow the user to edit the additional attributes of the row in the details presenter while they are entering the new row's information.

As a related question, is is possible to clear the details presenter when more than one row is selected?  As it works now it will keep displaying the detail for the first selected row of the group of selected rows which is rather confusing.

5 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 04 Jun 2010, 06:38 AM
Hello Andrew,

The GridViewNewRow has not details presenter, but we plan to add one for a future release.

Anyway, there is a very simple workaround. You can add a new data item and its row will become a "normal" row. Then you can toggle its row details manually. Here is how to do this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Data;
using Telerik.Windows.Controls;
using System.Collections.ObjectModel;
using Telerik.Windows.Controls.GridView;
 
namespace NewRowDetails
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
 
            this.clubsGrid.AddingNewDataItem += new EventHandler<Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs>(clubsGrid_AddingNewDataItem);
        }
 
        void clubsGrid_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
        {
            e.Cancel = true;
            Club newClub = new Club();
            ObservableCollection<Club> itemsSource = (ObservableCollection<Club>)this.clubsGrid.ItemsSource;
            itemsSource.Add(newClub);
            this.clubsGrid.CurrentItem = newClub;
 
            this.clubsGrid.ScrollIntoViewAsync(newClub, this.OnNewClubAdded);
        }
 
        private void OnNewClubAdded(FrameworkElement row)
        {
            ((GridViewRow)row).DetailsVisibility = Visibility.Visible;
        }
    }
}

There are many different configurations that you can achieve for row details visibility.

The display mode of the Row Details can be specified by using the RowDetailsVisibilityMode property. It can have one of the following values:

  • Collapsed - row details won't be displayed for any of the rows.
  • Visible - row details will be displayed for each of the rows.
  • VisibleWhenSelected - row details will be displayed only for the selected row.

Furthermore, you can specify visibility on a per-row basis by using the GridViewRow.DetailsVisibility like I have done above. So you can listen for selection events and toggle each row's details visibility according to your needs.

This help article discusses row details visibility. I have also attached a sample project. I hope this helps.

Sincerely yours,
Ross
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Daniel Meland
Top achievements
Rank 1
answered on 15 Sep 2010, 03:37 PM
This does not work!

I have been working on this for a while now and just cant get it to work..

I want to click the Add New Item bar and show the row as rowdetails not cells in edit mode.

 

 

private void OnAddNewRow(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)

 

{

e.Cancel =

 

true;

 

 

 

Workflow wf = new Workflow();

 

wf.ProductID =

 

"GL";

 

e.NewObject = wf;

 

 

this.WorkflowConfigGrid.ScrollIntoViewAsync(wf, (row) =>

 

{

((

 

GridViewRow)row).DetailsTemplate = (DataTemplate)WorkflowConfigGrid.RowDetailsTemplate;

 

((

 

GridViewRow)row).DetailsVisibility = Visibility.Visible;

 

});

}


Wont work.

Any ideas?

Thanks
Dan
0
Rossen Hristov
Telerik team
answered on 15 Sep 2010, 03:58 PM
Hello Daniel Meland,

It is not working, because you are not doing it like in the sample project I have provided.

Add the new object to the source collection, do not set it as e.NewItem.

Also, you do not need to do anything with the template. It is just a template.

If you do it like shown in the project -- it will work.

I hope this helps.

Regards,
Ross
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Daniel Meland
Top achievements
Rank 1
answered on 15 Sep 2010, 04:09 PM

 

 

Nope.

Now maybe this is because I am in WPF, but I doubt it.

OnNewClubAdded Never gets called.

Is there a dependency on ObservableCollection here? I dont think so.

Thoughts.

private
void OnAddNewRow(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)

 

{

e.Cancel =

 

true;

 

 

 

Workflow wf = new Workflow();

 

wf.WorkflowID = -1;

 

 

 

wf.ProductID =

 

"GL";

 

context.Workflows.Attach(wf);

context.SubmitChanges();

WorkflowConfigGrid.CurrentItem = wf;

 

 

this.WorkflowConfigGrid.ScrollIntoViewAsync(wf, OnNewClubAdded);

 

 

 

//{

 

 

 

// ((GridViewRow)row).DetailsVisibility = Visibility.Visible;

 

 

 

//});

 

}

 

 

 

private void OnNewClubAdded(FrameworkElement row)

 

{

((

 

GridViewRow)row).DetailsVisibility = Visibility.Visible;

 

}

 

0
Daniel Meland
Top achievements
Rank 1
answered on 15 Sep 2010, 04:34 PM
Ok thanks.

It is dependent on the ObservableCollection.

I get it.

Thanks
Dan
Tags
GridView
Asked by
Andrew
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Daniel Meland
Top achievements
Rank 1
Share this question
or