We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridDataControl -- Automatically show details view for selected row, and hide expander cell

Thread ID:

Created:

Updated:

Platform:

Replies:

108342 Apr 15,2013 12:58 PM UTC Dec 9,2013 09:54 AM UTC WPF 3
loading
Tags: GridControl
Sören Höglund
Asked On April 15, 2013 12:58 PM UTC

Hi,

so I have something like this:

        <syncfusion:GridDataControl Name="dataGrid"
                                    SelectedItem="{uxf:TwoWayBinding SelectedItem}"          
                                    ItemsSource="{uxf:TwoWayBinding Deliveries}">
            <syncfusion:GridDataControl.DetailsViewTemplate>
                <DataTemplate>
                    <StackPanel x:Name="details">
                        <local:DeliveryDetail />
                    </StackPanel>
                </DataTemplate>
            </syncfusion:GridDataControl.DetailsViewTemplate>
        </syncfusion:GridDataControl>

Which gives me the basics of what I need, but what I would like to do is always show the details for the currently selected row, and remove the ability to manually expand/hide the details.
 
What would be the easiest way to go about this?


Thangapriya V [Syncfusion]
Replied On June 24, 2013 03:51 AM UTC

Hi Soren,

Sorry for the delay caused.

We have analysed your requirements. You can achieve your requirement to show the details for the currently selected row by using cell click event as follows.

Code Snippet[C#]:

   void dataGrid_CellClick(object sender, Syncfusion.Windows.Controls.Grid.GridCellClickEventArgs e)

        {

                int recordindex = this.dataGrid.Model.ResolveIndexToRecordPosition(e.RowIndex);

                dataGrid.Model.Table.ExpandDetailsViewAt(recordindex);

        }

 

 

 

And there is no direct support for hiding expand collapse cell. We have prepared a workaround to achieve your requirement. You can refer the following code snippet for this.

Code Snippet[C#]:

void ColumnWidths_LineSizeChanged(object sender, Syncfusion.Windows.Controls.Scroll.RangeChangedEventArgs e)

        {

            if (dataGrid.Model.Table.HasDetailsView)

            {

                if (e.NewSize == GridDataTableModel.ExpandCollapseCellWidth)

                {

                    if (dataGrid.ShowRowHeader && e.From == 1)

                        dataGrid.Model.ColumnWidths[1] = 0;

                    if (!dataGrid.ShowRowHeader && e.From == 0)

                        dataGrid.Model.ColumnWidths[0] = 0;

                }

            }

        }

 

 

We have prepared a sample based on your requirements and please find the sample in the following location.

Please let us know if you have any queries.

Regards,

Thangapriya

 



DetailsView_c812a6b9.zip

Ankesh Suresh Maradia
Replied On December 4, 2013 01:59 PM UTC

On the click, i want to achieve two behaviors:

1) Expanding detail view on click, if it is closed. This is happening now.

2) Collapsing the detail view if i click on the row again, if the detail view is opened. Can you help with this?


Saravanan M [Syncfusion]
Replied On December 9, 2013 09:54 AM UTC

Hi Ankesh,

 

Thanks for your update,

 

We have analyzed your query. You can collapse the detail view while click on the row if detail view opened by using IsDetailsViewExpanded API.

You can refer the below code snippet.

 

Codesnippet[C#]:

dataGrid.CellClick += dataGrid_CellClick;

 

void dataGrid_CellClick(object sender, Syncfusion.Windows.Controls.Grid.GridCellClickEventArgs e)

{

     int recordindex = this.dataGrid.Model.ResolveIndexToRecordPosition(e.RowIndex);

     var nodeentry = this.dataGrid.Model.View.Records[recordindex] as GridDataRecord;

     if (nodeentry.IsDetailsViewExpanded)

        dataGrid.Model.Table.CollapseDetailsViewAt(recordindex);

     else

        dataGrid.Model.Table.ExpandDetailsViewAt(recordindex);

}

 

 

Please let us know if this solution helps you,

 

Regards,

Saravanan.M


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;