We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Hiding PrimaryKey column

Thread ID:





95735 Jul 27,2010 08:25 PM Jul 30,2010 08:14 AM ASP.NET MVC (Classic) 2
Tags: Grid
Administrator [Syncfusion]
Asked On July 27, 2010 08:25 PM

How do I hide the primary key column in a grid?

I have a products grid with an id column and name column, but I only want to display the product names.


- Rick

Krishnaraj D [Syncfusion]
Replied On July 28, 2010 05:00 AM

Hi Rick,

Your Incident has been updated. Please check it.

Krishnaraj D

Krishnaraj D [Syncfusion]
Replied On July 30, 2010 08:14 AM

Hi Rick,

While enabling paging/sorting/filtering/editing functionalities, you have to rebind the QuerycellInfo property again in post action since Essential Grid is fully ajax enabled. So for paging/sorting/filtering/editing actions the entire page will not be refreshed, the grid contents alone refreshing using ajax calls.

So the below methods is necessary to achieve the grid actions.

Please refer the below code snippets.


If you enabled the paging/sorting/filtering/editing features, rebind the QueryCellInfo property again in post action as below.

public ActionResult Index(PagingParams args)
IEnumerable data = new NorthwindDataContext().Orders.Take(200);

ActionResult result = data.GridActions();
var grid_Data = result as GridHtmlActionResult;
//rebinding the custom QueryCellInfo
grid_Data.GridModel.QueryCellInfo = this.QueryCellInfo;
return grid_Data;


//Custom QuerycellInfo
public void QueryCellInfo(GridTableCell cell)

if (cell.TableCellType == GridTableCellType.RecordFieldCell || cell.TableCellType == GridTableCellType.AlternateRecordFieldCell)

if (cell.Column.MappingName == "CustomerID")
if (cell.Data.Freight <= 30)
cell.HtmlAttributes["style"] = "color:Blue;background-color:Chocolate;";

If you feel inconvenient in redefining the custom QueryCellInfo in controller, then use the Html.RenderAction method in View to access the custom QueryCellInfo action in controller.

Refer the below code snippets.

.QueryCellInfo(currentCell => Html.RenderAction("QueryCellInfo", "Home", new { cell = currentCell }))

But we suggest that to use the first method as it’s not a fair programming strategy to go back to controller from view.

Krishnaraj D


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.