Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1049947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:41:43+00:00 2026-05-16T16:41:43+00:00

Has anyone come across a good solution for using ./Views/Shared/DisplayTemplates and ./Views/Shared/EditTemplates with the

  • 0

Has anyone come across a good solution for using ./Views/Shared/DisplayTemplates and ./Views/Shared/EditTemplates with the MvcContrib.UI Grid?

I guess I could wireup a CustomItemRenderer, but I would much rather be able to do something like:

<% Html.Grid<Person>(Model.People)
         .Sort(new GridSortOptions {Column = Model.Column, Direction = Model.Direction})
         .Columns(column =>
         {
           column.For(e=>e.Name);
           column.DisplayFor(e=>e.StartDate); // <-- I'd like to do this for DateTime.asxc
         }).Render();
%>

There may already be something in Grid to do this and I just haven’t found it yet. Any help would be greatly appreciated.

Thanks,

Hal

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:41:44+00:00Added an answer on May 16, 2026 at 4:41 pm

    I have acheived this by modifying the source code in the GridRenderer and GridColumn classes. The change in GridColumn is to add the following function:

    public object GetRawValue(T instance)
    {
      if (!_cellCondition(instance))
      {
        return null;
      }
    
      var value = _columnValueFunc(instance);
      return value;
    }
    

    Then the change in GridRenderer is in the RenderItem function to be changed as follows:

     protected virtual void RenderItem(GridRowViewData<T> rowData)
    {
      BaseRenderRowStart(rowData);
    
      HtmlHelper<T> html = new HtmlHelper<T>(Context, new ViewPage());
      foreach (var column in VisibleColumns())
      {
        //A custom item section has been specified - render it and continue to the next iteration.
        if (column.CustomItemRenderer != null)
        {
          column.CustomItemRenderer(new RenderingContext(Writer, Context, _engines), rowData.Item);
          continue;
        }
    
        RenderStartCell(column, rowData);
    
        var cellValue = column.GetRawValue(rowData.Item);
        if (cellValue != null)
        {
          //RenderText(cellValue.ToString());         
          MvcHtmlString value = html.DisplayFor<T, object>(m => cellValue);
          string str = (value.ToString() == string.Empty) ? cellValue.ToString() : value.ToString();
          if (column.HtmlEncode == true)
          {
            str = (value.ToString() == string.Empty) ? HttpUtility.HtmlEncode(cellValue.ToString()) : value.ToHtmlString();
          }
          RenderText(str);
        }
    
        RenderEndCell();
      }
    
      BaseRenderRowEnd(rowData);
    }
    

    Once you do this the grid will use the templates found. I have only tested with DisplayTemplates as this is all I need but it should also work for EditorTemplates with a slight change.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone come up with a good solution for deploying BlackBerry applications across different
Has anyone come across any good tools (preferably but not necessarily FOSS) that can
Wondering if anyone has written or come across a good way to log to
Has anyone come across an example of a non .Net consumer of an ADO.NET
Has anyone come across this issue? Seems MS have broken it with their own
Has anyone come across a Perl module that will parse (and write) kerberos configuration
Has anyone come up with a good way of performing full text searches (
Has anyone come across an effective way to mimic Webkit's -webkit-mask-box-image: url(filename.png) functionality? I'm
Has anyone come across an error like the following: Unable to cast object of
Has anyone come across a clean way to post tweets in wordpress with the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.