0

Is there any way to freeze column headers for ASP.net MVC Razor(.cshtml) when scrolling? I am not using a separate gridview library, at least not currently. I can use .cshtml, or alternatively (if needed) javascript or jquery.

One of our managers asked me this, and it is (IMHO) a good question.

Any help would be appreciated.

I don't have any freeze code attempted myself, however, per request, here is what the razor code looks like in Index.cshtml:

    <th class="headerStyle">
        @Html.DisplayNameFor(model => model.First().myColumn_1)
    </th>

and later:

     <td class="boxed_displayElementStyle">
            @Html.DisplayFor(modelItem => item.myColumn_1)
     </td>

I do want to allow the columns to have variable widths and variable header width (though each column having the same width as its header) so this complicates freezing the headers very greatly.

Thanks in advance!

JosephDoggie
  • 1,514
  • 4
  • 27
  • 57
  • 1
    can you post some of your view code? – Madison Feb 13 '15 at 16:15
  • I don't have any specific code to do this. The razor view is standard mvc, such as that in the edited question above (I am using the standard PagedList.Mvc, if that matters ....) – JosephDoggie Feb 13 '15 at 19:23
  • 1
    This kind of presentation isn't specific to the technology, it's a simply styling change. (Granted it may some out-of-the-box on previous controls, it can easily be duplicated in your own presentation). Have a look at [this post](http://stackoverflow.com/questions/15811653/table-with-fixed-header-and-fixed-column-on-pure-css) for more information on styling. – Brad Christie Feb 13 '15 at 19:30

1 Answers1

1

This kind of presentation isn't specific to the technology, it's a simply styling change. (Granted it may some out-of-the-box on previous controls, it can easily be duplicated in your own presentation). Have a look at this post for more information on styling.

Community
  • 1
  • 1
Brad Christie
  • 100,477
  • 16
  • 156
  • 200