RadGrid Hide Column but Send Data

11 posts, 1 answers
  1. Marcel
    Marcel avatar
    13 posts
    Member since:
    Mar 2012

    Posted 17 Apr 2012 Link to this post

    Hello everyone,
    i am trying to hide columns in a RadGrid through the OnColumnCreated-event in the code-behind.
    The Radgrid is bound to the Data in the PageLoad by just assigning a DataTable as DataSource.
    On the clientside the hidden columns should really just be hidden, so that i can access them through JavaScript because i want to react on OnRowClick and need the information.
    var grid = sender;
    var MasterTable = grid.get_masterTableView();
     
    var row = MasterTable.get_dataItems()[args.get_itemIndexHierarchical()];
     
    var value1= MasterTable.getCellByColumnUniqueName(row, "HiddenRow1").innerHTML;
    var value2= MasterTable.getCellByColumnUniqueName(row, "HiddenRow2").innerHTML;

    The OnRowClick then does an async postback by using the RadAjaxManager and then i can handle everything in the code behind but i still need those values.
    How can i hide columns and still get access them on the client side?
    Or is there a way to use just the rownumber to get the Row and its values on the server side?
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Apr 2012 Link to this post

    Hello Marcel,

    Try hiding the column using Display property rather than Visible property and then access the cell value. Here is the sample code that I tried which worked as expected.
    C#:
    protected void RadGrid1_ColumnCreated(object sender, Telerik.Web.UI.GridColumnCreatedEventArgs e)
    {
      if (e.Column.UniqueName == "UniqueName")
      {
        GridBoundColumn col = (GridBoundColumn)e.Column;
        col.Display = false;
      }
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Marcel
    Marcel avatar
    13 posts
    Member since:
    Mar 2012

    Posted 17 Apr 2012 Link to this post

    Works perfectly!
    Thanks.
  5. Srujan
    Srujan avatar
    18 posts
    Member since:
    Oct 2010

    Posted 07 Oct 2014 in reply to Princy Link to this post

    Hi Princy ,

    I have a masterdetail table , I am unable to hide column in details view , can you please suggest how to proceed .
  6. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 10 Oct 2014 Link to this post

    Hi Srujan,

    You can achieve this requirement either on server or client-side by using the Name property of the table views:
    <telerik:GridTableView ... Name="Customers">

    Hope this helps.

    Regards,
    Eyup
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. C
    C avatar
    43 posts
    Member since:
    Jul 2013

    Posted 19 Nov 2014 in reply to Princy Link to this post

    Hmmm, in my grid, the ColumnCreated event only fires for "ExpandCollapseColumn". It doesn't seem to fire for my GridBoundColumns?
  8. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 24 Nov 2014 Link to this post

    Hello,

    The RadGrid ColumnCreated event should fire for all kind of columns in RadGrid. Please make sure that you handle the event correctly and also that you are setting a breakpoints for the event itself and not for some condition in the handler which is not hit for Bound Columns.

    Regards,
    Maria Ilieva
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  9. C
    C avatar
    43 posts
    Member since:
    Jul 2013

    Posted 24 Nov 2014 in reply to Maria Ilieva Link to this post

    Yeah, well, I can't seem to get it to work.

    <telerik:RadGrid ...
    OnColumnCreated="rgActivities_OnColumnCreated" ...>
    ...
    </telerik:RadGrid>

    protected void rgActivities_OnColumnCreated(object sender, GridColumnCreatedEventArgs e)
        {
            if (e.Column.UniqueName != "EventDateID")
                return;
            var col = (GridBoundColumn)e.Column;
            col.Display = false;
        }

  10. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 26 Nov 2014 Link to this post

    Hi C,

    Can I kindly ask you to open a regular support ticket and send us isolated runnable version of your application? Thus we will be able to debug it locally and verify what exactly is causing the ColumnCreated event to not fire correctly.

    Regards,
    Maria Ilieva
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  11. Graham MacLeod
    Graham MacLeod avatar
    7 posts
    Member since:
    Oct 2009

    Posted 12 Jan in reply to Maria Ilieva Link to this post

    I'm observing the same behavior as 'C': the ColumnCreated event only fires for "ExpandCollapseColumn". It doesn't fire for any of the GridBoundColumns.  
  12. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 15 Jan Link to this post

    Hi Graham ,

    Note that this event fires only for auto-generated columns.


    Regards,
    Maria Ilieva
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017