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.
Syncfusion Feedback

input checbox in grid

Thread ID:

Created:

Updated:

Platform:

Replies:

90441 Oct 1,2009 12:04 PM UTC Oct 8,2009 05:06 AM UTC ASP.NET MVC (Classic) 3
loading
Tags: Grid
Pawel Szpytma
Asked On October 1, 2009 12:04 PM UTC

HI

I would like to add a column with an input type "checkbox" to the MVC grid. Is this possible?

THX in advance.

Balaji M [Syncfusion]
Replied On October 1, 2009 10:51 PM UTC

Hi Pawel,

Thank you for your interest in Syncfusion products.

We suggest you to use the Format option inside QuerycellInfo, in order to achieve this Checkbox inside Grid.

Please refer the following code snippet to achieve this.


public ActionResult Index()
{

GridPropertiesModel model = new GridPropertiesModel
{
DataSource=context.Students.Skip(0).Take(10),
Caption="Student List",
PrimaryKeyColumns={"ID"}
};
ViewData["GridModel"] = model;
model.QueryCellInfo += new GridTableCellStyleInfoEventHandler(model_QueryCellInfo);

return View();
}

void model_QueryCellInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
{
if (e.TableCellIdentity.Column.MappingName == "Result")
{
if ((bool)e.Style.CellValue)
e.Style.Format = "";
else
e.Style.Format = "";

e.Handled = true;
}
}
}

Please refer the sample from the below link.

http://files.syncfusion.com/support/grid_mvc/Incidents/F90441/Mvc_SampleGrid.zip

The Sample illustrates,

1. Result is column contains the boolean value.

2. Inside QueryCellInfo event, Result column in the grid formatted using style.Format property.


Please let me know if you have any concerns.

Regards,
M. Balaji

Pawel Szpytma
Replied On October 7, 2009 02:16 PM UTC

Hi,
I used the code recommended by you, but i'm having problems with sorting. When I sort the column, it changes from input type to normal text,

THX in advance.

Balaji M [Syncfusion]
Replied On October 8, 2009 05:06 AM UTC

Hi Pawel,

Thank you for your interest in Syncfusion product.

This is default behaviour of MVC Grid. We suggest you to bind QueryCellInfo event in ActionResult,in order to get the format at all pages.

Refer the below code snippet, which illustrates this.

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SortingAction(PagingParams args)
{
GridHtmlActionResult result = new GridHtmlActionResult();
result.GridModel.DataSource = context.Students.Skip(0).Take(10);
result.GridModel.QueryCellInfo += new GridTableCellStyleInfoEventHandler(model_QueryCellInfo);
return result;
}


Please refer the updated sample from the below link.
http://files.syncfusion.com/support/grid_mvc/Incidents/F90441/Mvc_SampleGrid1.zip

Please let me know if you have any concerns.

Regards,
M. Balaji.


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

;