Skip to content

Infragistics Community Forum / Web / Ultimate UI for ASP.NET Web Forms / Hide Columns and Rows at WebDataGrid

Hide Columns and Rows at WebDataGrid

New Discussion
Chris
Chris asked on Jul 22, 2013 6:51 PM

I am using the WebDataGrid, not the UltraWebDataGrid and I cant hide some columns of my grid.I want

to hide then at the grid prerender if this is possible.Mu columns are dynamically bounded and have no

specified keys.can anybody help me to hide some columns and rows?

Sign In to post a reply

Replies

  • 0
    [Infragistics] Aaron Marisi
    [Infragistics] Aaron Marisi answered on Jun 2, 2009 8:55 PM

    Hello Chris,

    As far as I have seen there is no built-in way to hide columns and rows. You may be able to mock the functionality of hiding columns by adding or removing GridFields from the GridFieldsCollection. You could potentially hide rows by applying a filter.

    Hope that helps.

    • 0
      TRE
      TRE answered on Sep 19, 2012 1:37 PM

      I find it disappointing:

      1) That you would suggest that there is no way to hide columns when it is documented in the help. http://help.infragistics.com/Help/NetAdvantage/ASPNET/2011.2/CLR4.0/html/WebDataGrid_Hiding_a_Column.html

      2) That this clearly was available since 2011.2 and I've upgraded to 2012 and this still isn't working.

      I get this error when using the Hidden property available for a BoundDataField:

      [HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
         System.Web.UI.ControlCollection.Add(Control child) +11415588
         Infragistics.Web.UI.Framework.AppStyling.CssBuilder.OnPreRenderComplete(Object sender, EventArgs e) +742
         System.EventHandler.Invoke(Object sender, EventArgs e) +0
         System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4543
      

      Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

      The reason for the need to hide columns is to have the data readily available whether it be in the browser or on the server. Most of my applications with the UltraWebGrid relied on this functionality. It looks like Bunty's solution should work, but this is something the grid should be doing on it's own. It's the sole purpose of buying 3rd party controls is to prevent us from having to create hacks for a usable UI.

      • 0
        Danny Thanigai
        Danny Thanigai answered on Jul 22, 2013 6:51 PM

        Here is the solution:

        VB.NET

        Protected Sub WebDataGrid1_InitializeRow(sender As Object, e As Infragistics.Web.UI.GridControls.RowEventArgs) Handles WebDataGrid1.InitializeRow

        If e.Row.Index = 0 Then

        e.Row.Items.FindItemByKey("CSMainID").Column.Hidden = True

        End If

        End Sub

        C#

        protected void WebDataGrid1_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e)
        {
        	if (e.Row.Index == 0) {
        		e.Row.Items.FindItemByKey("CSMainID").Column.Hidden = true;
        	}
        }
  • 0
    Bunty
    Bunty answered on Jun 3, 2009 3:48 PM

    Chris,

    Aaron is correct right now there is no intrinsic way to hide the columns from server side or using any property.

    Here is an alternate way to do so using CSS on Column level:

    Create a Css :

    .hideMyColumn
    {
    display:none;
    }

    and use this Css at column level like this

    this.WebDataGrid1.Columns[2].CssClass = "hideMyColumn";

    This will hide the column.

    Bunty 🙂

    • 0
      Chris
      Chris answered on Jun 3, 2009 4:16 PM

      Thanx a lot but I used the UltraWebGrid and had no problems.I have some more questions about Infragistiscs controls.

      1) I use filters at my ultrawebgrid and in order to make a cell editable to filter my grid (contains,like,=…etc) with some values I have to double click on the filter row.I also have a double click event and I have some conlicts.I want to make the filter row ediatble with one click.Is this possible?

      P.s.The double click event doesnt fire when i double click on the filter row…why?

       

      2)I have a webdialogwindow with a webpanel inside.The panel is collapsed when the page load.when i expand the panel some scroll bars appear because its height is too big.so, when i expand the panel I want to adjust the webdialogwindow width without a postback.is this possible?i'm trying with javascript but its not too easy

      • 0
        [Infragistics] Vince McDonald
        [Infragistics] Vince McDonald answered on Jun 23, 2009 9:03 PM

        Chris,

        [quote user="ChrisKapamaru"]Thanx a lot but I used the UltraWebGrid and had no problems.I have some more questions about Infragistiscs controls.[/quote]I recommend that you post new threads in the appropriate forums for these additional questions.  That way, it'll be easier for readers to track what each thread is about, what questions have been answered, and which threads involve ongoing issues.

        Normally, I would split a post like this off into its own thread.  However, since it's a reply to an earlier post on this thread, and also contains questions about two different controls, I can't simply split it off without doing significant editing.

        Thanks for your understanding.

    • 0
      Jayashree
      Jayashree answered on Dec 21, 2010 10:33 AM

      This is helpful Bunty. Thank you

      • 0
        Abhishek
        Abhishek answered on Sep 16, 2011 10:52 AM

        You can Use the following Code:

        this.WebDataGrid1.Columns["ColumnName"].Hidden = true;
        

  • 0
    David
    David answered on Jun 5, 2009 5:05 AM

    Sorry if i'm not understanding this, but I think you can remove columns using this code…(i've pasted this from the online help)

    ' REMOVE COLUMNS
    Me.WebDataGrid1.Columns.Remove(Me.WebDataGrid1.Columns("CompanyName1"))
    Me.WebDataGrid1.Columns.Remove(Me.WebDataGrid1.Columns("TemplateField1"))

    I guess you can put this in the DataBound event?

    EDIT
    this didn't work for me, just go with bunty's response…

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Chris
Favorites
0
Replies
9
Created On
Jul 22, 2013
Last Post
12 years, 7 months ago

Suggested Discussions

Created by

Created on

Jul 22, 2013 6:51 PM

Last activity on

Jul 22, 2013 6:51 PM