Home

Is there a simple way to hide object header display from Dump()?

I'm using Dump() to build a simple UI and would like it not to display the headers with the object information. What is the simplest way to do this?

This simple example

List<dynamic> list = new()
{
    new { A = "1", B = "xxx", Info = new { C = 1, D = "xxx", E = "xxx" } },
    new { A = "2", B = "xxx", Info = new { C = 2, D = "xxx", E = "xxx" } }
};

list.Dump();

displays as

but I would like it to display as

Is there a simple way to achieve that?

Comments

  • And what will happen if user presses Alt+2? How tables which have no headers will be collapsed?

  • If you are happy enough to remove all headers from everything that is dumped in your query, then you can call

    Util.RawHtml("<style>.typeheader {display: none}</style>").Dump();
    

    Note this even affects objects that are dumped before this line is called.

    Alt+2 behaves as you would expect, but Alt-1 may hide everything.

    If you only want to do this on one object, but are happy enough to remove headers on nested objects, then you could try

    Util.RawHtml("<style>.InvisibleTypeheader {display: none}</style>").Dump();
    Util.RawHtml(Util.ToHtmlString(true, list).Replace("<td class=\"typeheader\"", "<td class=\"InvisibleTypeheader\"")).Dump();
    
  • Thanks @sgmoore I'll give that a try.

    @i2van I'm not concerned about collapsing tables. It's a personal project and I will be the only user, which is why I wan't to use the standard Dump() functionality as much as possible rather than having to build my own UI as HTML.

  • It works perfectly for my needs and using the second method I find that passing enableExtensions:false to ToHtmlString() disables Alt+1 and Alt+2 so I needn't worry about accidentally hitting those keystrokes.

Sign In or Register to comment.