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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Hiding PrimaryKey column

Thread ID:

Created:

Updated:

Platform:

Replies:

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

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.

thanks

- Rick

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



Hi Rick,

Your Incident has been updated. Please check it.


Regards,
Krishnaraj D

Krishnaraj D [Syncfusion]
Replied On July 30, 2010 12:14 PM UTC

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.

Controller:

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

[AcceptVerbs(HttpVerbs.Post)]
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
[ChildActionOnly]
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.


Regards,
Krishnaraj D

CONFIRMATION

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.

Warning Icon 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.Close Icon

;