Way to hide a column?

7 posts, 0 answers
  1. Jonathan Miller
    Jonathan Miller avatar
    57 posts
    Member since:
    Jun 2008

    Posted 17 Sep 2008 Link to this post

    I have a dataset that is  a master/detail, displaying as hierchical data.

    The 2 tables are joined on a column called "InvoiceID"

    I do not want to show the "InvoiceID" column in the detail data

    Without defining every column that should be displayed in xaml, is there a way to specify a column that I want to hide?  Thanks

  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2018 posts
    Member since:
    Sep 2012

    Posted 22 Sep 2008 Link to this post

    Hello Jonathan ,

    Yes , there is a way to show only specific columns from your datatable in the hierarchy child datatable without specifying the column in the XAML. A similar approach is shown in the Hierarchy/TableHierarchy example in our examples application (QSF).

    Please take a look at the code of the example. There is a column called 'OrderID' used for the relation without actually showing the column in the UI. I believe the shown approach is similar to what you are up to.

    If the example does not help enough let me know so that I can prepare a sample application for you. In this case I will need a few lines from your code (those related to the databinding of the grid) .

    Greetings,
    Pavel Pavlov
    the Telerik team


    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

  3. DevCraft Release
  4. jas
    jas avatar
    20 posts
    Member since:
    Jul 2006

    Posted 22 Aug 2009 Link to this post

    Could you please give an actual example, with code, of how to hide columns.

    The application you refer to has OrderID fully visible on both levels of the heirarchy!

    My grid xaml is:

            <telerik:RadGridView  
                ItemsSource="{Binding Persons}"  
                AutoGenerateHierarchyFromDataSet="True" 
                ShowGroupPanel="False" 
                Grid.Column="1"  
                Grid.Row="2"  
                Margin="10,10,10,10"  
                Name="radGridView1"  
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"  
                ClipToBounds="False" /> 
     

    Persons is a large object containing collections (e.g. addresses), but I only want to display, on this view, a few columns from it. Which is the best way to do this? [control version is current at Aug'09]

    jas

  5. ManniAT
    ManniAT avatar
    825 posts
    Member since:
    Nov 2003

    Posted 22 Aug 2009 Link to this post

    Hi,

    since you use autogenerated columns the columns "exist" at the moment the data is loaded.
    So you should handle the things in the "DataLoaded" event of the RadGridView.
    There you can iterate through the columns and set "IsVisible" to false for the columns you want to hide.
    A simple example (just hiding the first columns) would look like this:

        private void radGridView1_DataLoaded(object sender, EventArgs e) {  
                radGridView1.Columns[0].IsVisible = false;  
            } 

    Regards

    Manfred
    PS: if this post was helpfull pleas set "Mark as answer"

  6. jas
    jas avatar
    20 posts
    Member since:
    Jul 2006

    Posted 22 Aug 2009 Link to this post

    Thanks for the very quick reply!

    I am aiming to subscribe to MVVM principles with this design and thus keep the code-behind to a minimum - and have just found a solution in XAML (which is little different from doing it in code-behind, but neater maybe).

    In XAML and with AutoGenerateColumns="False" I will just specify the columns needed in this sort of way:

                <telerik:RadGridView.Columns> 
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding CName}" Header="Name" /> 
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding SName}" Header="Surname" /> 
                </telerik:RadGridView.Columns> 
     
    as I only need about four columns from about ten possible.

    Regards

    James.
    ps: can't immediately see how to 'mark as answer' but perhaps it wil lbe apparent when I post this... Nope - I must be blind/stupid - how do I mark your reply thus?

  7. ManniAT
    ManniAT avatar
    825 posts
    Member since:
    Nov 2003

    Posted 22 Aug 2009 Link to this post

    OK,

    that's different. Your "sample code" showed a grid with autogenerated columns.
    And in this case there is no way to do the things declarative.
    If you don't need to have autogeneration your solutions is the correct approach of course.
    You simply define what you need to display :)

    And sorry about the "mark as answer" - since you are not the originator of this thread you can't do it.
    I've simply overseen this fact.

    Regards

    Manfred

  8. jas
    jas avatar
    20 posts
    Member since:
    Jul 2006

    Posted 22 Aug 2009 Link to this post

    That explains it!

    Cheers,

    James.

Back to Top
DevCraft Release