RowDetailsTemplate display problem

18 posts, 0 answers
  1. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 21 Jun 2012 Link to this post

    Hi,

    I'm using Telerik V2012.1.325.35 and I have a strange problem RowDetailsTemplate. In my project, I have a main RadGridView and all object in his ItemsSource a "IsDeleted" member of type bool. On the "RowLoaded" of my main RadGridview, I do the following to hide all object with the "IsDeleted" == true and everything working fine:

    private void gvExams_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
    {
         ExamForBilling theExam = e.DataElement as ExamForBilling;

                if (theExam != null && e.Row != null)
                {
                    e.Row.Visibility = theExam.IsDeleted ? Visibility.Collapsed : Visibility.Visible;
                }
    }

    In my main grid, I have a RowDetailsTemplate that contain another RadGridView with RowLoaded event where I do the samething to hide deleted object. The problem is for every deleted object, the grid display a blank row. Here is the RowLoaded code of my RowDetailsTemplate RadGridView (screenshot attached):

            private void RadGridView_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
            {
                BilledExamsForBilling theExam = e.DataElement as BilledExamsForBilling;

                if (theExam != null && e.Row != null)
                {
                    e.Row.Visibility = theExam.IsDeleted ? Visibility.Collapsed : Visibility.Visible;
                }
            }

  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 22 Jun 2012 Link to this post

    Hi Oliver,

    That would be the expected behavior since you are setting the visibility of the row to collapse. Please take a look at our documentation for further reference.
    What you would rather do is to work with the underlying data items and add/ remove them. 

    Greetings,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 22 Jun 2012 Link to this post

    Hi Maya,

    removing object in the underlying data are not a got approach for me :( When I delete an object, I have to mark it as deleted and send it back to my back-end for database IO.

    I'm I missing something in your explanations (ie: underlying data!!!) ?!?

    Thank's
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 25 Jun 2012 Link to this post

    Hello Oliver,

    As mentioned previously, it is not recommended to work with the visual elements of a virtualized control like RadGridView. If you want to remove an item, why not using filtering ?  

    Kind regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 25 Jun 2012 Link to this post

    Hi Maya,

    I added the following piece of code in my XAML under my RadGridView tag:

                    <telerik:RadGridView.FilterDescriptors>
                        <telerik:CompositeFilterDescriptor LogicalOperator="And">
                            <telerik:CompositeFilterDescriptor.FilterDescriptors>
                                <telerik:FilterDescriptor Member="IsDeleted" Operator="IsNotEqualTo" Value="True"/>
                            </telerik:CompositeFilterDescriptor.FilterDescriptors>
                        </telerik:CompositeFilterDescriptor>
                    </telerik:RadGridView.FilterDescriptors>

    and when I change the IsDeleted member of the SelectedItem to TRUE, the item still visible in my grid.

    Thank's
  6. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 26 Jun 2012 Link to this post

    Hello Oliver,

    I have tested the case and everything works correctly on my side. Could you take a look at the sample attached and let me know whether I am missing something ?  

    Kind regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  7. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 26 Jun 2012 Link to this post

    Hi Maya,

    seem's to work but if I want to filter on a field using binding, is it possible? How?

    Thank's
  8. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 27 Jun 2012 Link to this post

    Hello Oliver,

    Could you clarify a bit on your exact requirements ? Do you want to bind the Value of the filter descriptor ? Does the solution illustrated in this forum thread correspond to your requirements ? 

    Regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  9. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 27 Jun 2012 Link to this post

    Hi Maya,

    what I'm trying to do know is with a CompositeFilterDescriptor, I want to filter on a property which contain a GUID and the GUID value is not the same on every customer site. That why I cannot, in this situation, using a harcoded value like: <telerik:FilterDescriptor Member="IsDeleted" Operator="IsNotEqualTo" Value="True"/>
     
    Thank's
  10. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 29 Jun 2012 Link to this post

    Hi Maya,

    let me express mysel in a different way :)

    Actually in my ItemsSource, I have a property that it's not visible in my grid, it's a GUID property representing the status of the object itself (MarkAsAdded, MarkAsModified or MarkAsDeleted). Each status have a different GUID and thos GUID's are not the same on each site.

    In my application, the user can right-click on an item in a grid and change the status of the object to MarkAsDeleted, at this time, I want to hide the object from the grid. After marking for deletion many object in the grid, the user have to click on a button to save his changes, at this moment, I'm looking for each object who was marked for deletion and I send them to my back-end for a database io operation.

    Thank's
  11. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 02 Jul 2012 Link to this post

    Hello Oliver,

    Based on the scenario that you described, I get the impression that it will be better to remove the items "MarkAsDeleted" for example from the source collection and fill it in another one. Afterwards, when you click the "Save" button, you will know all those that have been removed and will be able to send them back to your database and perform the actions you want.
    Am I right or am I missing something from your requirements ?  

    Kind regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  12. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 02 Jul 2012 Link to this post

    Hi Maya,

    I can do it as you suggest but I though I could do it the way I did it :(

    Thank's
  13. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 19 Jul 2012 Link to this post

    Hi Maya,

    if I try: MyGridView.Items.Remove(MyGridView.SelectedItem)
    I fall in the following exception:

    System.NotSupportedException: La collection était d'une taille fixe.
       à System.Array.System.Collections.IList.Remove(Object value)
       à Telerik.Windows.Data.QueryableCollectionView.RemoveItemFromSourceList(Object removedItem) dans c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.Editing.cs:ligne 439
       à Telerik.Windows.Data.QueryableCollectionView.Remove(Object item) dans c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.Editing.cs:ligne 421
       à Telerik.Windows.Data.DataItemCollection.Remove(Object item) dans c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\DataItemCollection.Editing.cs:ligne 398
       à com.christiegrp.Neuron.ClientApplication.VisitBillingDetails.deleteCurrentExam()
       à com.christiegrp.Neuron.ClientApplication.VisitBillingDetails.CommandBinding_DoDelete(Object sender, ExecutedRoutedEventArgs e)

    Thank's
  14. Trevor
    Trevor avatar
    6 posts
    Member since:
    Feb 2012

    Posted 06 Feb 2013 Link to this post

    The issue is that the row is not collapsing when the GridViewRow visibility is set to Collapse.  Instead, it is just disappearing from view as if  visibility was being set to "Hidden".    

     <telerik:RadGridView.Resources>
                                        <Style TargetType="{x:Type telerik:GridViewRow}">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding ObjectState}" Value="3">
                                                    <DataTrigger.Setters>
                                                        <Setter Property="Visibility" Value="Collapsed" />
                                                    </DataTrigger.Setters>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
    </telerik:RadGridView.Resources>
  15. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 07 Feb 2013 Link to this post

    Hi Trevor,

    It is not recommended to work with the visibility of row. Since RadGridView is virtualized, it recycles and reused its visual elements like cells and row. You can take a look at this article for a reference.
    What you can try instead is either to filter the collection so that the item you want is not displayed in the grid or remove it from the source.  


    All the best,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  16. Trevor
    Trevor avatar
    6 posts
    Member since:
    Feb 2012

    Posted 07 Feb 2013 Link to this post

    Regardless of the recommendation, should the expected WPF behavior not apply?   Now I have to program to your controls specific interpretation of Visibility and that is not a good thing from my perspective.    Thanks for the reply.
  17. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 07 Feb 2013 Link to this post

    Hi Trevor,

    Working with the visibility of the rows will break the virtualization of the control. This would be true for any other virtualized control as well - DataGrid, RadTreeListView, ListBox, etc.  

    All the best,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  18. Trevor
    Trevor avatar
    6 posts
    Member since:
    Feb 2012

    Posted 07 Feb 2013 Link to this post

    Forget about Virtualization for a moment.  The code below works on the data grid:

    <DataGrid.RowStyle>
                                    <Style TargetType="DataGridRow">
                                        <Setter Property="Visibility" Value="{Binding ObjectState, Converter={StaticResource StateVis}}" />
                                    </Style>
                                </DataGrid.RowStyle>


    The Converter returns "Collapsed" if ObjectState meets some condition.  In this case the entire row of the DataGrid collapses.  In the Telerik RadGridView, the row is simply hidden and a blank row persists.   If I only intend to show a very small amount of data, I don't care about Virtualization, but I do care about the control working with my view model.

    Anyhow, this thread is getting more of my attention than intended.  I will move along, but I am not thrilled with the proposed solution.

    Thanks again.
Back to Top